Tuesday, September 16, 2014

Struggling with One to One relationships

Hi

I have a super class Job that will never be instantiated on it's own,
although is not Meta.

There are two other models, WorkshopJob and EngineeringJob, which have
o2o links to a Job.

On creation of either WorkshopJob and EngineeringJob, a new Job is made.

The problem arises because any particular job may have both other
types linked to it - some Jobs will only be linked to either/or, but
some will have both.

Regardless of that, there will only ever be one WorkshopJob and or one
EngineeringJob per job.

I am struggling to create the second object - when I try to create a
new WorkshopJob from an existing EngineeringJob (ie, linking the
underlying Job id number to the as yet unsaved new Workshop job),
creation fails.

Is it because I have parent_link=True on both subclasses? Is it
because the o2o will only allow a single FK on an object? Or is it
possible - I've just made a mistake somewhere else (I tried CBVs, I
tried FBVs, nada).

Cheers
L.

--
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiPCFnB9wFPXb6cJOk%2BYHWZ-KUtZjXZHPR%2Bbdyx7L2GYNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment