Saturday, November 20, 2010

problems with model inheritance if base class is not abstract

Hi all! I'm new to django and I'm experimenting with models but I have
some trouble. I've minimized my problem to this code:

class TestBase(models.Model):
base = models.CharField(max_length=255)

from django.contrib import admin
class TestA(TestBase):
testb = models.CharField(max_length=255)

admin.site.register(TestA)

class TestB(TestBase):
testc = models.CharField(max_length=255)

admin.site.register(TestB)

Trying to add TestA instances from admin interface I have this error:
Cannot assign "''": "TestA.testb" must be a "TestB" instance.

why testb should be a TestB instance?? It's a simple field!

If TestBase is declared as abstract using the internal Meta Class I no
more have the error. Is this a bug or there is something that I don't
understand?

Thanks in advance :)

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate