1👍
✅
AFAIK, Django doesn’t have builtin support for that. select_related
never changes the outcome of a queryset, only the number of queries when you access related object.
You could use DjangoFullSerializers to get something that is similar to what you want.
0👍
Implement the unicode method of each Model, and print it.
class Book(..):
title = models.CharField(..)
color = models.CharField(...)
author = models.ForeignKey('Author')
...
def __unicode__(self):
return u"%s %s %s" %(title, color, author)
class Author(...):
name = models.CharField(...)
...
def __unicode__(self):
return name
- [Django]-Unique email constraint for django.contrib.auth.user
- [Django]-Internet Explorer does not talk with django dev server
- [Django]-Pass a lazy translation string including variable to function in Django
- [Django]-Django over https form redirection issues
Source:stackexchange.com