On Sun, May 16, 2010 at 4:58 AM, Jori <jtla...@gmail.com> wrote: > Hi, > > I have a problem when using MIT in my models. I created two new > classes which inherit model Entry: > > class Entry(models.Model): > LANGUAGE_CHOICES = settings.LANGUAGES > > language = models.CharField(max_length=2, > verbose_name=_('Comment language'), choices=LANGUAGE_CHOICES) > user = models.ForeignKey(User) > country = models.ForeignKey(Country, null=True, blank=True) > > created = models.DateTimeField(auto_now=True) > > class Comment(Entry): > comment = models.CharField(max_length=2000, blank=True, > verbose_name=_('Comment in English')) > [remainder snipped]
The problem seems to be that you have named a field in your Comment model with the same name, only lower case. Comment inherits from Entry, using multi-table-inheritance. This adds a OneToOneField in Comment back to Entry, which has a side-effect of adding a 'comment' attribute to Entry. This is the attribute that lets you access the Comment associated with the Entry as a result of the OneToOneField in Comment, and by default it is given the name of the related model, all-lowercase. The problem then occurs when the Comment model "inherits' all the fields/attributes of Entry: the inherited 'comment' attribute from Entry is apparently over-riding the specified comment field. That's probably a bug, but it appears to have been there since 1.0. I have not done any research to see if it's been reported. As a workaround you can name your fields something other than the model name all lowercased, or you can explicitly specify the OneToOneField in the child models, specifying parent_link=True and something other than the model name all lowercased for related_name. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.