46👍
✅
QuerySet.only()
and QuerySet.defer()
can be used to refine which fields the ORM will pull, deferring the others until the appropriate attributes on the models are accessed.
- [Django]-DRY way to add created/modified by and time
- [Django]-How to customize activate_url on django-allauth?
- [Django]-ManyRelatedManager object is not iterable
6👍
if you need just the values as a dictionary use objects.values(”). Its also faster.
see docs: http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
- [Django]-Capture parameters in django-rest-framework
- [Django]-Django datetime issues (default=datetime.now())
- [Django]-Django – Simple custom template tag example
Source:stackexchange.com