python - Join in Django based upon foreign key -
python - Join in Django based upon foreign key -
my model this
class news(models.model): idnews = models.integerfield(primary_key=true) source = models.textfield(blank=true) title = models.textfield(blank=true) class nounplural(models.model): idnoun_plural = models.integerfield(db_column='idnoun_plural', primary_key=true) # field name made lowercase. nns = models.textfield(db_column='nns', blank=true) # field name made lowercase. news_idnews = models.foreignkey(news, db_column='news_idnews') my view this
projapp.models import news projapp.models import nounplural result = nounplural.objects.select_related() when nounplural.objects.select_related() nounplural fields not news field.what want in queryset have fields of nounplural , title field of news. how acheive that?
python django
Comments
Post a Comment