Let's assume we have a model:
class a(models.Model):
users = models.ManyToManyField(User) # django.contrib.auth.models.User
and these variables:
user = request.user
queryset = a.objects.all()
Then I want to exclude these records from a model that contains the user in users. How can I do that?
queryset.exclude(...)
It's as simple as this:
queryset.exclude(users=user)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With