Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple models with AutoOneToOneField to model. #33

Open
wess opened this issue Jan 9, 2015 · 2 comments
Open

Multiple models with AutoOneToOneField to model. #33

wess opened this issue Jan 9, 2015 · 2 comments

Comments

@wess
Copy link

wess commented Jan 9, 2015

When you have, say, 3 models, 1 is primary, and the other 2 both have AutoOneToOneField, only one model/relationship is auto created.

@brmc
Copy link

brmc commented Oct 28, 2015

Can confirm that it doesn't work quite right with multiple o2o's, but it seems to SOMETIMES create more than one. On my current project, I have a model with 5 AutoOneToOne fields. On the initial save, 2 or sometimes 3 o2o models are created, but never all 5

@brmc
Copy link

brmc commented Oct 29, 2015

@wess, in case you're wanting the models to be immediately visible in the admin after a save, here's a quick hack that seems to work. put this in your str model method(or unicode if you're using python 2):

for x in self._meta.related_objects:
            if x.one_to_one:
                hasattr(self, x.get_accessor_name())

It isn't reliable in the save method for some reason, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants