Best way to filter ListView with drop down form in Django

后端 未结 2 867
故里飘歌
故里飘歌 2021-02-10 23:57

I\'m trying to filter a ListView based on Users, using a drop down form.

models.py

class Post(models.Model):
    ...
    author = models.ForeignKey(\'aut         


        
2条回答
  •  感情败类
    2021-02-11 00:23

    In your form, try changing this:

    
    

    to this:

    
    

    Then, in your view:

    if author_filter:
        result = Post.objects.filter(author_id=int(auth_filter))     
    

提交回复
热议问题