shiva
unread,Apr 3, 2012, 11:34:50 PM4/3/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello!
In our apps (that use Django 1.2.7) we use following models:
class BaseRegistration(models.Model):
exhibition = models.ForeignKey(...)
year = models.IntegerField(...)
user = models.ForeignKey('auth.User')
class BarcodeRegistration(BaseRegistration):
class Meta:
abstract = True
class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)
I append *validate_unique* by *user* and *event* fields in
EventRegistration class:
class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)
user = models.ForeignKey('auth.User')
class Meta:
unique_together = ('event', 'user')
But in django command manage.py validate fails with error:
exhibition.eventregistration: "unique_together" refers to user. This
is not in the same model as the unique_together statement.
After some "pdb'ing" of django.core.management.validation,
django.db.models.base, and django.db.models.options I found, that is
happend because:
In [13]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.parents.keys()[0]._meta.local_fields
Out[13]: True
In [14]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.local_fields
Out[14]: False
Is it's something wrong with our code?
Thanks
--
Shavrin Ivan