On Tue, 2007-08-21 at 21:21 -0700, Catriona wrote:
> Hello
> 
> Is it possible to have multiple one-to-one relationships for a single
> class or is there a better way to do it.

Not at the moment, no. OneToOneFields assume they are going to be the
primary key, so you're restricted to a single one. This is something we
will fix in the future, since there are legitimate uses.

If you wanted to dive deep, you could look in
django/db/models/fields/related.py and try to fix this yourself,
although I suspect it isn't completely trivial (it's not impossible,
just not a five minute job).

> What I have is an event which has about 12 fields. Optionally any
> combination of a single weather record, a single event detail record,
> a single survey record and one of four event subclass records may be
> stored against this event. Each of these optional records has between
> 5 and 12 fields each. I could put everything in one big table with
> lots of nullable fields but that is not my preferred option.

You can fake it with a ForeignKey, since that only allows one entry on
the source model's end. The slight drawback is that each target instance
(say, an event detail record) is not prohibited from being linked from
two different event models by the database. Some checking in the save()
method could fake this for you, though.

Regards,
Malcolm

-- 
Borrow from a pessimist - they don't expect it back. 
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