Hi,
I am using OneToOneField to simulate model inheritance. I
have all the
shared fields in a base model, and then for every specific
case I have
a derived model that has a OneToOneField to that base model.
That was
all working fine.
Recently I was trying to encapsulate some of the
functionality that is
in all the derived models into a base class. So I have
something
similar to the following:
---------------
class Base(models.Model):
common_field = models.CharField()
class CommonFunc(models.Model):
def save(self):
do_common_thing()
super(CommonFunc,self).save()
class DerivedModel(CommonFunc):
base = models.OneToOneField(Base)
specific_field = models.CharField()
---------------
The problem I am having is that for some reason it is not
detecting
that the one-to-one field is a primary key and when I syncdb
it gives
me an error that DerivedModel has two primary keys since
django adds
the implicit id field.
Is this a bug? Is there a better way for me to achieve this?
Or should
I just wait patiently until model inheritance is
implemented?
--
Thanks,
Medhat
--~--~---------~--~----~------------~-------~--~----~
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://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|