7👍
✅
If you know you’re passing in N
pks, then a count()
query filtered by those pks should have exactly N
results.
def do_exist(model, pks):
return model.objects.filter(pk__in=pks).count() == len(pks)
👤AKX
1👍
qs = MyModel.objects.filter(id__in=pks)
This gives you a queryset that you can apply .all() etc to
- [Django]-Model inheritance in django-nonrel on app engine
- [Django]-Prevent emails from Python from being flagged as spam
- [Django]-In Django, is there an easy way to render a text field as a template, in a template?
- [Django]-In stripe checkout page display Country or region fields how to remove it
- [Django]-Why does Google ReCaptcha not prevent the submission of the form?
- [Django]-Django Test – South migration reports 'no such table' but I can see said table in the db
- [Django]-Django message once logged in
Source:stackexchange.com