On Tue, Jul 21, 2009 at 10:12 PM, Jonas Obrist<ojiido...@gmail.com> wrote: > > In the documentation I see that there are Many-To-One Fields, > Many-To-Many Fields and One-To-One Fields. What about a One-To-Many > Field? You might now say that this is completely pointless since a > Many-To-One Field reversed is basically what I want. But I'd say that in > some cases it makes more sense to define a One-To-Many Field (because it > makes more sense to do it in Model A instead of Model B or whatever).
While I can see the reason why this is appealing from a data modeling perspective, a quick look at the underlying mechanics quickly reveals the reason why this hasn't been implemented. If a model A has a foreign key on model B, then the table for A requires a field to track the relation. However, if model B has a "many to one" on A.... table A requires a field. This makes the process of rolling out new models could lead to some surprising situations. For example, with the current suite of relation fields, you can always add a new model, run syncdb, and know that your tables will be correct. However, this won't be the case if you allow ManyToOne fields - you need to have the additional constraint that the model to which you are linking hasn't been created yet. In short, something that is a relatively simple from a data modeling perspective has the potential to open all sorts of SQL management problems. Of course, this sort of thing would be much easier to handle if there was a baked in schema evolution framework - but we don't have one of those.... yet :-) > Related to this is that I'd say it would be favorable if reversed > relationships could be edited through the admin page by default. This is a separate issue, but one that is more likely to get support - although the real fix is to correct the underlying forms handling to allow for the reverse relationships, not to fix admin specifically. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---