How to filter from two conditions?
I have a model for user groups:
class ProfileGroup(models.Model): user = models.ManyToManyField(user) name = models.CharField(max_length=100)
And a model for article:
class Article(models.Model): title = models.CharField(max_length=200) text = models.TextField() group = models.ForeignKey(ProfileGroup) owner = models.ForeignKey(user)
The user can edit own articles and articles from groups which is assigned.
How to retrieve all user articles and from his groups? Do I need to use Q? Maybe suffice filter?
articles = Article.object.filter(....
To get a user's articles:
To get articles that belong to one of the user's groups.
You can then get use Q to get articles which belong to that user or one of the user's groups.