3👍
✅
If i understand your question right you have a specific site
and your trying to filter
by that site. Then you should filter like this:
site = Site.objects.get(pk=1)
mymodel_for_site = MyModel.objects.filter(field1=thing, sites=site)
This should get all the MyModel instances for a particular site
-1👍
Try to make it via MyModel object, i.e.:
object = MyModel.objects.get(field1=thing)
qs = object.sites.all()
Check django docs
- [Answered ]-Convert POST to PUT with Tastypie
- [Answered ]-Django manytomany field invalid literal for int() with base 10: ''
- [Answered ]-Access model name in Django CreateView from template
- [Answered ]-How Can I follow A Link to a specific post and scrape the data from the
- [Answered ]-Django, showing only matches condition in lookup
Source:stackexchange.com