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

setting relations using the relation_id generated by django in field_values #68

Open
ajrouvoet opened this issue Jul 10, 2015 · 4 comments

Comments

@ajrouvoet
Copy link

I noticed today that this doesn't work. Nasty, because my tests now failed randomly, which was hard to debug. Is this something that can be fixed?

@gregmuellegger
Copy link
Owner

Can you throw in a little example code as it's a little hard to guess what you mean by the subject :)

@ajrouvoet
Copy link
Author

Sorry, was in a hurry ;-)

In the following snippet I used to have 'user_id': liduser.pk instead.

AutoFixture(Profiel, field_values={
    'voornaam': 'LID',
    'status': Profiel.STATUS.LID,
    'user': liduser,
}).create(1)

Which I expected to work because that's how django deals with relations usually.

@gregmuellegger
Copy link
Owner

Seems valid. What is the benefit for you to use user_id over user? What happens if you set an integer to the user field? Does that work?

I see the problem you have. But I probably won't get around to fix it soonish. Would you be interested in working on a fix for this?

@ajrouvoet
Copy link
Author

Setting an integer to the user field is invalid in Django. The benefit is mostly that if you don't have a whole instance, you can still set the related value (without incurring extra costs for getting the instance).

The problem is not that I really want to use this feature though, it's more that it fails very silently and is thus hard to debug. Making it fail obviously by throwing some error would already be a big improvement.

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

No branches or pull requests

2 participants