On Tue, 2008-02-12 at 12:44 +0100, Hanne Moa wrote:
> On Feb 12, 2008 12:16 PM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> > On Tue, 2008-02-12 at 12:11 +0100, Hanne Moa wrote:
> > > Each org only has a single region, and in the old web-interface the
> > > region-data is shown as a drop-down-list (<select>) where you can
> > > choose one and only one. So: org.region == region.id, there can be
> > > many orgs in a region but only one region per org.
> >
> > Which means it's many-to-one, not one-to-one. If you were to draw a
> > picture of your table rows, many rows would (potentially) be pointing to
> > a single row in the org table. That's many-to-one.
> >
> > In Django a many-to-one relation is represented by a ForeignKey field.
> 
> I'm using a ForeignKey-field for it now, but I don't see anywhere how
> to make it behave as in the old system: in Django's admin-interface
> for org the foreignkey is shown as a drop-down *but with nothing
> selected*.
> 
> When looking at the examples in the tutorial: Poll/Choice, a Poll can
> have several Choices, but a Choice can have only a single Poll. But
> org->region is *the other way around*. One Poll containing many
> Choices vs. one org having one region. The fact that one region have
> many orgs is irrelevant as region will never be editable or visible
> anywhere else but as linked from org.
> 
> So, how do I do that?

Put the ForeignKey on the "many" side of the relation. In your case, it
looks like it goes on the "org" model, since there are many orgs to a
region.

> 
> > If you're just starting out, you're going to want to spend a bit of time
> > searching in the django-users archives (or just searching in Google and
> > making sure "django" is in the query). There are very few 'new'
> > questions of this nature.
> 
> Then where's the FAQ?

http://www.google.com/search?q=django+FAQ

Regards,
Malcolm

-- 
For every action there is an equal and opposite criticism. 
http://www.pointy-stick.com/blog/


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

Reply via email to