Tuesday, January 31, 2012

field name hiding workaround

Hello,

I have got a class Lexeme which I would like to define as follows:

class Lexeme(models.Model):

class Meta:
unique_together = ((u"entity", u"language"),)

language = models.ForeignKey(Language)

# ...

I would like to have different types of lexemes, each of which has
another field type as "entity". Like so:


class CommodityLexeme(Lexeme):

class Meta:
verbose_name_plural = "Commodities"

entity = models.ForeignKey(Commodity)


class CountryLexeme(Lexeme):

class Meta:
verbose_name_plural = "Countries"

entity = models.ForeignKey(Country)


I know this doesn't work, because field name hiding is not permitted.
(See https://docs.djangoproject.com/en/1.1/topics/db/models/#field-name-hiding-is-not-permitted).

But what would be the most elegant workaround? I suppose someone has
had a similar problem before.

Jaroslav

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment