On 12/2/07, Vivek Khurana <[EMAIL PROTECTED]> wrote: > > > On Dec 2, 2007 12:27 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> > wrote: > > > The reason for this kind of approach is that I should be able to > > > upgrade the core without affecting the extensions created by > > > developers. > > > > > > > To my regret, Django model inheretance, is not yet working. > > > > More info here: > > http://code.djangoproject.com/wiki/ModelInheritance > > > > We have also found this. Building quick sites is very easy with > > Django. Building 'framework' to build > > something is difficult. For example here, we are making a e-commerce > > software framework based on Django. > > Well i did a test after this posting. I created a class called Box as > following > > class Box(models.Model): > width = models.IntegerField() > height = models.Integer(Filed() > > then inherited a class from box as fllowing > > class Box2(Box): > color = modles.IntegerFiled() > > Now when i build this model into the db it created two tables Box and > Box2. Where Box2 has all the fields of Box plus the color filed. So we > can say Model inheritance is working and I am fine with it too.
No, really, model inheritance is currently unsupported, meaning the result of subclassing models like this is undefined, likely to break in unexpected ways, subject to change without warning or migration path in the future, and really something you do not want to do. Besides, as you see, it doesn't currently do what you want anyway. But > what I am looking is a mechanism so that when I make any changes to > Box model those are reflected in Box2 also while the additional fields > of box2 are untouched. > Should i build a separate table for custom fields ? or is there any > mechanism which I am overlooking. You probably want to use the same approach as Alex and use OneToOne fields. > > > Every e-commerce store have its own set of attributes associated with > > product. To make it possible, we have created > > basic models (Product,Category) and related customProduct, > > customCategory to them. This allows end users and > > developers to extend models, without inheritance, and without touching > > basic tables. All this is working via OneToOne > > relationship, which is not yet fully supported in Django, so we > > maintain 5 patches to Django source code only to make > > our software working. > > > > Are these patches available some where ? I'd hope the problems have been reported in trac with fixes available as patches in tickets. But a query of non-closed tickets with OneToOne in the summary and patches available brings up only four tickets: http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&summary=%7EOneToOne&has_patch=1&order=priority and of course I don't know if these actually overlap at all with the problems/patches Alex is referring to. But looking in trac for OneToOne-related tickets would be a good idea if you're going to use OneToOne fields -- there aren't actually that many open tickets for them. Alex says OneToOne is not fully supported, but I'd characterize them rather as supported but liable to change in the future, as mentioned in the doc: http://www.djangoproject.com/documentation/model-api/#one-to-one-relationships Since they are documented, and seem to be the recommended way of achieving something like model inheritance, I'd expect the future changes to have a migration path. That is, when a backwards-incompatible change is made to them I expect it will be announced with notes on how to migrate your app to accommodate the new behavior. Which means for myself I wouldn't be scared off of using them just because of the note in the doc about future changes. But I'm just guessing based on how I've seen things handled in this project over the last year plus; I have no direct knowledge of plans for OneToOneField changes. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

