Hello, everyone! I hope someone can help me here.
I'm trying to create an intermediate model hierarchy for data migration purposes (I'm using South). Basically I want to move 'phone' field (see below) from 'Call' model to its parent non-abstract 'Service' model and I need an intermediate state where this field exists in both parent and child models. After reading this: http://docs.djangoproject.com/en/1.1/topics/db/models/#field-name-hiding-is-not-permitted I understand that it is not permitted to hide field name in child model and django would raise a FieldError exception. And that's exactly what happens: class Phone(models.Model): pass class Service(models.Model): phone = models.ForeignKey(Phone, related_name='services') class Call(Service): phone = models.ForeignKey(Phone, related_name='calls') > manage.py validate django.core.exceptions.FieldError: Local field 'phone' in class 'Call' clashes with field of similar name from base class 'Service' works as expected... no problem However, if I add new 'IntermediateService' model like this: class Phone(models.Model): pass class Service(models.Model): phone = models.ForeignKey(Phone, related_name='services') class IntermediateService(Service): class Meta: abstract = True class Call(IntermediateService): phone = models.ForeignKey(Phone, related_name='calls') ...surprisingly it validates: > manage.py validate 0 errors found and sqls for postgresql: > manage.py sql app CREATE TABLE "app_phone" ( "id" serial NOT NULL PRIMARY KEY ); CREATE TABLE "app_service" ( "id" serial NOT NULL PRIMARY KEY, "phone_id" integer NOT NULL REFERENCES "app_phone" ("id") DEFERRABLE INITIALLY DEFERRED ); CREATE TABLE "app_call" ( "service_ptr_id" integer NOT NULL UNIQUE REFERENCES "app_service" ("id") DEFERRABLE INITIALLY DEFERRED, "phone_id" integer NOT NULL REFERENCES "app_phone" ("id") DEFERRABLE INITIALLY DEFERRED ); So what is it? Bug, hidden feature or what? Thank you! Vasily
-- 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.