On Fri, 2009-01-02 at 16:29 -0800, carlopires wrote: > Hi, > > I'm trying Multi Table Inheritance with: > > class Person(models.Model): > name = CharField(max_length=30) > > class Student(Person): > course = CharField(max_length=30) > > on db shell: > > p = Person(name='Carlo') > p.save() > > Why I can't: > > s = Student(p) > s.save() > > ? > How Can I evolute a Person to Student ?
You can't. At least at the moment -- it's a sometimes requested feature, but there are arguments against allowing it as well. Maybe one day we'll add it. Realise that you can't do this in Python, either, which is why it's not completely weird. If B is a subclass of A and you have an instance of A, you cannot create an instance of B that is an evolved version without copying all the data from the first instance into a new B instance. That's exactly what you need to do here. Copy all the p items into the Student constructor. So, in this way, model inheritance behaves like Python (which is always the intention, as much as possible -- although leaky abstractions interfere in both directions at times). Regards, Malcolm > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---