Hi Malcolm

Thanks for the awesomely quick reply.

I'll give the foreign key option a go for now and maybe dive deep
later.

I'm assuming that I could check for say an existing event detail
record when I try and create a new one as well - probably cause less
user angst.

Thanks again

Catriona

On Aug 22, 2:42 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> 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 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to