0👍
Photo.photoviewtset.all()
will fetch you all PhotoViewT
instances associated with that Photo
.
Photo.photoviewtset.filter(user=<your_current_user)
will fetch you all PhotoViewT
instances associated with that Photo
filtered by your current_user
.
Note: You do not need the ManyToManyField in the Photo
model for this
- [Answer]-Url – issues when rendering search results with Haystack / Whoosh jquery
- [Answer]-Make tag as variable for using in if::else in Django Template
- [Answer]-Django admin form – ManyToMany behavior with ForeignKey
- [Answer]-Issues with path in PyCharm; VirtualEnv
- [Answer]-Redirect URL with Argument in urls.py in Django 1.6.5
0👍
Photo.objects.exclude(viewsT__in=PhotoViewT.objects.filter(user=request.user))
OR
Photo.objects.filter(~Q(viewsT__in=PhotoViewT.objects.filter(user=request.user)))
- [Answer]-Code doesn't work in template
- [Answer]-Django: Matching query does not exist and django.core.exceptions.ImproperlyConfigured
Source:stackexchange.com