>class Lexeme(models.Model):
>
> class Meta:
> unique_together = ((u"entity", u"language"),)
I beleive this will not work because Lexeme is not abstract, and
it has no 'entity' field.
> 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).
You have not hidden any field names (note that the restriction
only applies to fields inherited from models.Model, not other
attributes, like the Meta class).
>But what would be the most elegant workaround? I suppose someone has
>had a similar problem before.
I think you can just move the "unique_together" into the Meta
classes for your Lexeme subclasses, and it should work as you
expect.
--
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