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.
43
With django 1.8:
use the values_list
Entry.objects.values_list('id', 'headline')
- [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