hello.I am ran in truble.I change my Model,also database,but the query result is unchange.. my BlogEntry model is:
class Entry(models.Model): title = models.CharField('title',maxlength=100) content = models.TextField('content') catelog = models.ForeignKey(Catelog,verbose_name='catelog',null=True) author = models.ForeignKey(Account,verbose_name='author') blog = models.ForeignKey(Blog,verbose_name='belong') create_at = models.DateTimeField('createdtime') status = models.IntegerField('status') last_update_at = models.DateTimeField('updatedtime') comment_enable = models.BooleanField('allow comment') ip = models.IPAddressField('ip') comment_count = models.IntegerField('commentCount') editor_type = models.IntegerField('editor_type') last_update_by = models.CharField('updatedby',maxlength=20,null=True) the query is : entries = blog.entry_set.filter (status=1).select_related(depth=1).order_by('-id') I display the entries on the template,also display the entry's catelog name. {{entry.catelog.name}} I found that,because of the nullable attribute 'catelog',django send 1 + N sql stement to database. so I have to change the attribute catelog not null: before: catelog = models.ForeignKey(Catelog,verbose_name='catelog',null=True) after: catelog = models.ForeignKey(Catelog,verbose_name='catelog') and then i modify my database.make the catelog_id column not null. but i find the result render on the page didn't correct.I want to get the author name by {{entry.author.name}} actually,django print the value of {{entry.blog.caption}}.this is the problem! I have compare the sql sent to database.the sql statment had changed.but the query reslut seems wrong.why?and how to fix ?thanks! -- site:http://www.fallever.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---