model-bakery 1.20.2__py3-none-any.whl → 1.20.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of model-bakery might be problematic. Click here for more details.
- model_bakery/__about__.py +1 -1
- model_bakery/baker.py +10 -4
- model_bakery/recipe.py +3 -0
- {model_bakery-1.20.2.dist-info → model_bakery-1.20.4.dist-info}/METADATA +1 -1
- {model_bakery-1.20.2.dist-info → model_bakery-1.20.4.dist-info}/RECORD +7 -7
- {model_bakery-1.20.2.dist-info → model_bakery-1.20.4.dist-info}/WHEEL +0 -0
- {model_bakery-1.20.2.dist-info → model_bakery-1.20.4.dist-info}/licenses/LICENSE +0 -0
model_bakery/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.20.
|
|
1
|
+
__version__ = "1.20.4"
|
model_bakery/baker.py
CHANGED
|
@@ -70,6 +70,10 @@ def _valid_quantity(quantity: Optional[Union[str, int]]) -> bool:
|
|
|
70
70
|
return quantity is not None and (not isinstance(quantity, int) or quantity < 1)
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
def _is_auto_datetime_field(field: Field) -> bool:
|
|
74
|
+
return getattr(field, "auto_now_add", False) or getattr(field, "auto_now", False)
|
|
75
|
+
|
|
76
|
+
|
|
73
77
|
def seed(seed: Union[int, float, str, bytes, bytearray, None]) -> None:
|
|
74
78
|
Baker.seed(seed)
|
|
75
79
|
|
|
@@ -513,10 +517,7 @@ class Baker(Generic[M]):
|
|
|
513
517
|
if isinstance(field, ForeignRelatedObjectsDescriptor):
|
|
514
518
|
one_to_many_keys[k] = attrs.pop(k)
|
|
515
519
|
|
|
516
|
-
if hasattr(field, "field") and (
|
|
517
|
-
getattr(field.field, "auto_now_add", False)
|
|
518
|
-
or getattr(field.field, "auto_now", False)
|
|
519
|
-
):
|
|
520
|
+
if hasattr(field, "field") and _is_auto_datetime_field(field.field):
|
|
520
521
|
auto_now_keys[k] = attrs[k]
|
|
521
522
|
|
|
522
523
|
if BAKER_CONTENTTYPES and isinstance(field, GenericForeignKey):
|
|
@@ -643,8 +644,13 @@ class Baker(Generic[M]):
|
|
|
643
644
|
if not attrs:
|
|
644
645
|
return
|
|
645
646
|
|
|
647
|
+
# use .update() to force update auto_now fields
|
|
646
648
|
instance.__class__.objects.filter(pk=instance.pk).update(**attrs)
|
|
647
649
|
|
|
650
|
+
# to make the resulting instance has the specified values
|
|
651
|
+
for k, v in attrs.items():
|
|
652
|
+
setattr(instance, k, v)
|
|
653
|
+
|
|
648
654
|
def _handle_one_to_many(self, instance: Model, attrs: Dict[str, Any]):
|
|
649
655
|
for key, values in attrs.items():
|
|
650
656
|
manager = getattr(instance, key)
|
model_bakery/recipe.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import collections
|
|
2
|
+
import copy
|
|
2
3
|
import itertools
|
|
3
4
|
from typing import (
|
|
4
5
|
Any,
|
|
@@ -79,6 +80,8 @@ class Recipe(Generic[M]):
|
|
|
79
80
|
mapping[k] = v.recipe.prepare(_using=_using, **recipe_attrs)
|
|
80
81
|
elif isinstance(v, related):
|
|
81
82
|
mapping[k] = v.make
|
|
83
|
+
elif isinstance(v, collections.abc.Container):
|
|
84
|
+
mapping[k] = copy.deepcopy(v)
|
|
82
85
|
|
|
83
86
|
mapping.update(new_attrs)
|
|
84
87
|
mapping.update(rel_fields_attrs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model-bakery
|
|
3
|
-
Version: 1.20.
|
|
3
|
+
Version: 1.20.4
|
|
4
4
|
Summary: Smart object creation facility for Django.
|
|
5
5
|
Project-URL: Homepage, https://github.com/model-bakers/model_bakery
|
|
6
6
|
Author-email: berin <bernardoxhc@gmail.com>, amureki <amureki@hey.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
model_bakery/__about__.py,sha256=
|
|
1
|
+
model_bakery/__about__.py,sha256=x1q-h5_vC69ihHWPy-P7qgYiRu7mDn_bOvPh67wLL8c,23
|
|
2
2
|
model_bakery/__init__.py,sha256=yY0xZUrr_mskBm07iF-MFBEiXzOuKrlMwpKWkXZs8v0,31
|
|
3
3
|
model_bakery/_types.py,sha256=P0iKC5-Cnh3lyzyZs1mlCfOW31zbEZpxqWCuYonucKo,130
|
|
4
|
-
model_bakery/baker.py,sha256=
|
|
4
|
+
model_bakery/baker.py,sha256=7mEXQvY3ISDFnL3rV-4T9WpCTwggSHrztJzimo0BFLk,31276
|
|
5
5
|
model_bakery/content_types.py,sha256=3POJ12aqPuSvCdKYuwb1GlJpSocgByG2JW5kw7VBNxQ,395
|
|
6
6
|
model_bakery/exceptions.py,sha256=q1oBZvfxL7HAD-F9aWgiYs4P4rz-hJ5TjeX7gcb3Q0I,333
|
|
7
7
|
model_bakery/generators.py,sha256=weuPptRtWnznjXGB658ftLQtSj5RMwngx-ryBXapNjE,5173
|
|
@@ -10,10 +10,10 @@ model_bakery/mock_file.txt,sha256=CO5zPS6Uydk48ZRnGcRKVEYKd2YjaUMa9QOgF5gGMCo,10
|
|
|
10
10
|
model_bakery/mock_img.jpeg,sha256=iF2ybgAVtDvl48-8VKdv_QFHKfnqeOaeGwR6ZLexJkY,1916
|
|
11
11
|
model_bakery/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
model_bakery/random_gen.py,sha256=3rvZCg5px6NOY1Q3fHSqw51BY6iQfCmOoRX4SsCOp6U,10084
|
|
13
|
-
model_bakery/recipe.py,sha256=
|
|
13
|
+
model_bakery/recipe.py,sha256=rBiKxUhhc35GphptDcvv8R30yH5qXxvMigxKwHUJxhI,8568
|
|
14
14
|
model_bakery/timezone.py,sha256=IvrzSer02FkUd_8DcJVOwTcRzeBn4qZ2pYvcI3QOr9E,345
|
|
15
15
|
model_bakery/utils.py,sha256=NjUsWuPmCYy6kHLjWmYnH7l-MVqlqiqSh7uq1U7EWaI,4635
|
|
16
|
-
model_bakery-1.20.
|
|
17
|
-
model_bakery-1.20.
|
|
18
|
-
model_bakery-1.20.
|
|
19
|
-
model_bakery-1.20.
|
|
16
|
+
model_bakery-1.20.4.dist-info/METADATA,sha256=i0Qk_jhf4s0VQcBlNEOMQfDDJpgmPnP_kNShSPemS-E,4406
|
|
17
|
+
model_bakery-1.20.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
model_bakery-1.20.4.dist-info/licenses/LICENSE,sha256=kCwHls7z8Y7NyZCmdnV1qLSdLrQ8bHrXLji5HOasgUc,611
|
|
19
|
+
model_bakery-1.20.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|