Andrew schrieb:
> That's a good thought, but unfortunately that's not
the way multiple
> inheritance works... only the first method in the
chain gets called.
Ah, your right. Although you can still call
models.Model.save() in your
ChangeImplementor.save() yourself, or even do something
like:
class Description(ChangeImplementor, models.Model): pass
class ChangeImplementor(object):
def save(self):
s = super(ChangeImplementor, self)
if hasattr('save', s):
s.save()
Although it probably starts to get a bit hackish...
Michael
Andrew schrieb:
> That's a good thought, but unfortunately that's not the
way multiple
> inheritance works... only the first method in the chain
gets called.
>
> On Dec 15, 6:54 am, Michael Elsdörfer <mich... elsdoerfer.info>
> wrote:
>>> class Description(ChangeImplementor,
models.Model):
>>
>> I might have a flaw in my logic, but if you were to
switch the
>> bases, inherit from models.Model first, and
implemented a save() in
>> ChangeImplementor, models.Model.save() should be
called first,
>> create the row, and by the time
ChangeImplementor.save() is
>> executed, you should have access to the primary
key.
>>
>> Maybe worth a try.
>>
>> Michael
> >
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|