Sanjay!

On 11 April 2013 18:00, Sanjay Bhangar <[email protected]> wrote:
> Lachlan,
>
> Not sure if I grokked your problem exactly, but just from personal
> experience when I found my brain turned to jelly with a similar-sounding
> issue before, I believe I found the answer in the "symmetrical=False" option
> .. I do believe setting symmetrical=False for your 'parents' and 'children'
> fields maybe a good first step toward figuring this out -- I did find that
> automatic creation of symmetrical relations in this case to be a bit
> confusing if you aren't expecting it. And, also, just thinking about it --
> do you actually need two separate fields for parents and children? Why not
> just --
>
> children = models.ManyToManyField("self", related_name='parents',
> verbose_name="Children", symmetrical=False, null=True, blank=True)

Good point - although potentially Mike's answer is good too - to have
a through table that describes each relationship ...But now that I
think about it, I don't want to store any more information about the
relationship, so potentially Mike's solution is too broad/abstract.

> Tbh, still not sure why your above example did not work:
>>>> bob = Account(first_name="bob",last_name="sanders",gender='M')
>>>> sarah = Account(first_name="sarah",last_name="sanders",gender='F')
>>>> bob.siblings.add(sarah)
>
> This is not something silly like needing to call bob.save() and sarah.save()
> before adding the m2m, is it ?

Ah, yes. That was it. "Buggrit, buggrem, see if i don't! Millenium
hand and shrimp!"

cheers
L.

--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to