We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi there,
I took this example RelatedFactory and modified it with the "name" field.
Here is my source code:
# models.py class User(models.Model): pass class UserLog(models.Model): user = models.ForeignKey(User) name = models.CharField() action = models.CharField() # factories.py class UserFactory(factory.DjangoModelFactory): FACTORY_FOR = models.User log = factory.RelatedFactory(UserLogFactory, 'user', name='test', action='create')
This caused the following error:
TypeError: __init__() got multiple values for keyword argument 'name'
The text was updated successfully, but these errors were encountered:
That's indeed a nasty bug, due to the fact that the second argument to RelatedFactory is called 'name'.
RelatedFactory
I'll rename it to "factory_related_name", with deprecation warnings; that might take a couple of releases.
In the meantime, could you see if the following definition works for you:
class UserFactory(factory.DjangoModelFactory): FACTORY_FOR = models.User log = factory.RelatedFactory(UserLogFactory, 'user', action='create') log__name = 'test'
Sorry, something went wrong.
declarations: Rename RelatedFactory.name (See #58).
38dfde0
Use less conflict-prone factory_related_name. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
This should be fixed in the v2.1.0 release.
Thank you for the update. Now its working fine.
No branches or pull requests
Hi there,
I took this example RelatedFactory and modified it with the "name" field.
Here is my source code:
This caused the following error:
The text was updated successfully, but these errors were encountered: