Re: Model Inheritance.
On 29/10/10 00:04, Tom Eastman wrote:
> That's correct, but I want to take a 'Place' object, that doesn't have a
> 'restaurant', and turn it *in to* a 'Restaurant' by adding the
> corresponding row to the Restaurant table.
So you have a place.
p = Place(name="3rd Circle of Hell")
p.save()
This should work:
r = Restaurant(serves_hot_dogs=True)
r.place_ptr = p
r.save()
If you then want an r that has picked up the now-should-be-inherited
place attrs, you'll have to do something like:
r = Restaurant.objects.get(pk=r.pk)
print r.name
3rd Circle of Hell
--
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