Hey everyone,
I'm currently attempting to design my first Django application. The model framework seems to be pretty nice -- it reminds me a bit of Apple's Core Data, except more geared toward web development. The model for my application conceptually needs something like model inheritance, as described near the beginning of the [wiki article] [1] of the same name. That is, I would love to do something like the following: class Place(models.Model): name = models.CharField(maxlength=50) class Restaurant(Place): type_of_food = models.CharField(maxlength=50) class Hotel(Place): price_per_night = models.FloatField() This models the 'object-oriented' nature of things -- restaurants and hotels are both places and should thus share the properties of places. Being a Cocoa/Core Data guy myself, the snippet above is the most natural way I can think of to do things. It sounds like Django is moving toward that, but I'm disappointed to see that doing it that way and having things automatically sorted out by the model layer isn't possible today. So can anyone tell me what the best way is to model such a relationship is _today_? It looks like a one-to-one key might work, but the reference documentation warns against it and, more importantly, I'm not positive it will do exactly what I want and don't exactly know how to accomplish it. I've seen some relevant discussions in the list archives, but they are a bit old and mostly related to the admin interface, which I am not extremely concerned with. Here are some points I'm looking for. They're mostly just what you would expect from an object-oriented system (and how things work in Core Data). Hopefully someone can tell me how to accomplish all of this. 1. If I ask for a list Places matching certain criteria, then Hotels, Restaurants, and basic Places matching the criteria should all be returned. 2. If I get a list of Places as above, then I should be able to tell whether a given object in the list is a Hotel or Restaurant or whatever and get and set its associated properties. 3. Restaurants and Hotels should be their own independent entities. If there is some crazy stuff going on with foreign keys and multiple tables behind the scenes, it should stay behind the scenes as an implementation detail. So if I delete a Hotel object, it should automatically delete the associated Place object if there is such a thing in the implementation. Can anyone help me with this? So far it's the only thing I've come across in Django that doesn't seem natural and well thought out. Thanks in advance for any help. Aaron [1]: http://code.djangoproject.com/wiki/ModelInheritance --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---