-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 sjtirtha declared: > Hi, > > I'm new in Django and now I'm already facing the issue with Model > Inheritance. > Here is my imagination, how the model should like > > class Document(models.Model): > name = ... > type = .... > > > class Media(Document): > link = .... > type = .... > class Meta: > abstract = True > > class Image(Media): > size = ..... > > Is this Model possible? It should only generate two DB tables > (Document and Image), where Image inherits the attributes from Media.
You probably shouldn't have "type = ..." on both classes. My experience with Django is that it doesn't like this, because it won't know which one to use when you have an instance of Media. Unlike most Python objects, Django model objects don't know what their most specific type is, and thus can't determine whether they are a Document or a Media. Hopefully, this will be fixed soon! You should know that this will generate three DB tables. The media and document tables will share primary keys, with the media table defining any fields not found in the document table. - -- Randy Barlow Software Developer The American Research Institute http://americanri.com 919.228.4971 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpWdJEACgkQw3vjPfF7QfV1BQCfd+GVi7/iL3T4/isD2ouTtWFj QpQAoJrOLkWdSRU5QyXfPqnJH5LgiNKg =izFF -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---