-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
_save_kwargs
inside of a recipe definition overridden
#308
Comments
I'm seeing the same with With this recipe, I now get: ...
File "/srv/www/studentenportal/apps/documents/models.py", line 159, in exists
return os.path.exists(self.document.path)
File "/usr/local/lib/python3.7/site-packages/django/db/models/fields/files.py", line 58, in path
self._require_file()
File "/usr/local/lib/python3.7/site-packages/django/db/models/fields/files.py", line 40, in _require_file
raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
ValueError: The 'document' attribute has no file associated with it. |
Hey @jeremy-engel, Thanks for the great issue report with the test patch! That helped a lot during the investigation. And I am sorry it took us so long to process the report. @The-Compiler and thank you for sharing another failing case! I came up with a draft solution in #330, which is not quite elegant (given my lack of experience with typed things). I'd love to hear your opinions here. @model-bakers/core please, take a look as well, maybe you have some ideas on improving this piece. Best, |
@jeremy-engel @The-Compiler hey! It took us a while, but we released a new version that is addressing this issue. Please, at your convenience, take a look at 1.7.0 and check if this solves everything for you! |
This release takes care of it for me. Thanks! |
I'm a bit late to the party as well, but indeed I just upgraded from 1.4.0 to 1.7.0 without any issues - thanks, @amureki! |
Fantastic, thanks everyone, for the cooperation! 💯 |
As a result of #292, when certain attributes are passed as arguments to
Recipe
, they are overridden by defaults before the recipe is used to create the object.Expected behavior
When using a recipe such as
my_recipe = Recipe("MyModel", _save_kwargs={"foo": "bar"})
, by runningbaker.make_recipe(my_recipe)
, thekwargs
for the model'ssave
should include the keyfoo
with valuebar
.Actual behavior
The
kwargs
are empty using this recipe. This contrasts withmy_recipe_2 = Recipe("MyModel")
, where by runningbaker.make_recipe(my_recipe_2, _save_kwargs={"foo": "bar"})
, the correctkwargs
are used.Reproduction Steps
Below are updates to the project test files demonstrating the issue.
And as a patch:
Versions
Python: 3.10.4
Django: 4.0.3
Model Bakery: 1.5.0
The text was updated successfully, but these errors were encountered: