Thursday, October 8, 2009

Automatic primary keys at model inheritance

Hello,
I am using django 1.1 and I discovered this problem:
I have models like these
-------------------------------
class Place(model.Models)
...

class Restaurant(Place)
...

class Bar(Place)
...
-------------------------------

the primary key counters for Restaurant and Bar classes are separated, which causes me troubles, because I want a Place to be Restaurant or Bar not both.

Example:
I create first Restaurant it has pk (place_ptr_id) = 1 and its Place has pk (id) = 1
Then I create first Bar and it has pk (place_ptr_id) = 1 and its Place has pk (id) = 1 instead what I expect (Bar.place_ptr_id = Place.id = 2).

I think this may cause a lot of trouble in case you want to have multiple children models for one parent model (even if you want Place to be both, Restaurant and Bar, because there is not an easy way to extend Place to Bar, when you have a Restaurant or Place, or I have not found it).

I wonder if it is bug or a feature. If it is feature I can not find out what is it useful for.

Vlastimil

--~--~---------~--~----~------------~-------~--~----~
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


Real Estate