model-bakery 1.20.3__py3-none-any.whl → 1.20.5__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "1.20.3"
1
+ __version__ = "1.20.5"
model_bakery/baker.py CHANGED
@@ -83,7 +83,7 @@ def make(
83
83
  _model: Union[str, Type[M]],
84
84
  _quantity: None = None,
85
85
  make_m2m: bool = False,
86
- _save_kwargs: Optional[Dict] = None,
86
+ _save_kwargs: Optional[Dict[str, Any]] = None,
87
87
  _refresh_after_create: bool = False,
88
88
  _create_files: bool = False,
89
89
  _using: str = "",
@@ -97,7 +97,7 @@ def make(
97
97
  _model: Union[str, Type[M]],
98
98
  _quantity: int,
99
99
  make_m2m: bool = False,
100
- _save_kwargs: Optional[Dict] = None,
100
+ _save_kwargs: Optional[Dict[str, Any]] = None,
101
101
  _refresh_after_create: bool = False,
102
102
  _create_files: bool = False,
103
103
  _using: str = "",
@@ -111,7 +111,7 @@ def make(
111
111
  _model,
112
112
  _quantity: Optional[int] = None,
113
113
  make_m2m: bool = False,
114
- _save_kwargs: Optional[Dict] = None,
114
+ _save_kwargs: Optional[Dict[str, Any]] = None,
115
115
  _refresh_after_create: bool = False,
116
116
  _create_files: bool = False,
117
117
  _using: str = "",
@@ -155,7 +155,7 @@ def prepare(
155
155
  _quantity: None = None,
156
156
  _save_related: bool = False,
157
157
  _using: str = "",
158
- **attrs,
158
+ **attrs: Any,
159
159
  ) -> M: ...
160
160
 
161
161
 
@@ -166,7 +166,7 @@ def prepare(
166
166
  _save_related: bool = False,
167
167
  _using: str = "",
168
168
  _fill_optional: Union[List[str], bool] = False,
169
- **attrs,
169
+ **attrs: Any,
170
170
  ) -> List[M]: ...
171
171
 
172
172
 
@@ -176,7 +176,7 @@ def prepare(
176
176
  _save_related: bool = False,
177
177
  _using: str = "",
178
178
  _fill_optional: Union[List[str], bool] = False,
179
- **attrs,
179
+ **attrs: Any,
180
180
  ):
181
181
  """Create but do not persist an instance from a given model.
182
182
 
@@ -590,9 +590,6 @@ class Baker(Generic[M]):
590
590
  else:
591
591
  field.fill_optional = field.name in self.fill_in_optional
592
592
 
593
- if _is_auto_datetime_field(field):
594
- return True
595
-
596
593
  if isinstance(field, FileField) and not self.create_files:
597
594
  return True
598
595
 
@@ -647,8 +644,13 @@ class Baker(Generic[M]):
647
644
  if not attrs:
648
645
  return
649
646
 
647
+ # use .update() to force update auto_now fields
650
648
  instance.__class__.objects.filter(pk=instance.pk).update(**attrs)
651
649
 
650
+ # to make the resulting instance has the specified values
651
+ for k, v in attrs.items():
652
+ setattr(instance, k, v)
653
+
652
654
  def _handle_one_to_many(self, instance: Model, attrs: Dict[str, Any]):
653
655
  for key, values in attrs.items():
654
656
  manager = getattr(instance, key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: model-bakery
3
- Version: 1.20.3
3
+ Version: 1.20.5
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>
@@ -12,6 +12,7 @@ Classifier: Framework :: Django
12
12
  Classifier: Framework :: Django :: 4.2
13
13
  Classifier: Framework :: Django :: 5.0
14
14
  Classifier: Framework :: Django :: 5.1
15
+ Classifier: Framework :: Django :: 5.2
15
16
  Classifier: Intended Audience :: Developers
16
17
  Classifier: License :: OSI Approved :: Apache Software License
17
18
  Classifier: Operating System :: OS Independent
@@ -47,76 +48,79 @@ Description-Content-Type: text/markdown
47
48
  [![Latest PyPI version](https://img.shields.io/pypi/v/model_bakery.svg)](https://pypi.python.org/pypi/model_bakery/)
48
49
  [![Documentation Status](https://readthedocs.org/projects/model-bakery/badge/?version=latest)](https://model-bakery.readthedocs.io/en/latest/?badge=latest)
49
50
 
50
- *Model Bakery* offers you a smart way to create fixtures for testing in
51
- Django.
52
- With a simple and powerful API you can create many objects with a single
53
- line of code.
51
+ *Model Bakery* offers you a smart way to create fixtures for testing in Django. With a simple and powerful API, you can create many objects with a single line of code.
54
52
 
55
- Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
53
+ > **Note:** Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
56
54
 
57
- ## Install
55
+ ## Installation
58
56
 
59
57
  ```bash
60
58
  pip install model-bakery
61
59
  ```
62
60
 
63
- ## Usage and Info
64
-
65
- ### Basic usage
61
+ ## Basic usage
66
62
 
67
63
  ```python
68
-
69
64
  # models.py
70
-
71
65
  from django.db import models
72
66
 
73
67
  class Customer(models.Model):
74
- enjoy_jards_macale = models.BooleanField()
75
68
  name = models.CharField(max_length=30)
76
69
  email = models.EmailField()
77
70
  age = models.IntegerField()
71
+ is_jards_macale_fan = models.BooleanField()
78
72
  bio = models.TextField()
79
- days_since_last_login = models.BigIntegerField()
80
73
  birthday = models.DateField()
81
74
  last_shopping = models.DateTimeField()
82
75
 
83
76
  # test_models.py
84
-
85
77
  from django.test import TestCase
86
78
  from model_bakery import baker
87
- from pprint import pprint
88
79
 
89
80
  class TestCustomerModel(TestCase):
90
81
  def setUp(self):
91
82
  self.customer = baker.make('shop.Customer')
92
- pprint(self.customer.__dict__)
83
+ print(self.customer.__dict__)
93
84
 
94
85
  """
95
86
  {'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
96
87
  'age': 3841,
97
88
  'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
98
89
  'birthday': datetime.date(2019, 12, 3),
99
- 'enjoy_jards_macale': True,
90
+ 'email': 'rpNATNsxoj@example.com',
91
+ 'is_jards_macale_fan': True,
100
92
  'id': 1,
101
93
  'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
102
- 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',
103
- 'days_since_last_login': 6016}
94
+ 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'}
104
95
  """
105
-
106
96
  ```
107
97
 
108
- Check out [documentation](<http://model-bakery.readthedocs.org/>) for more complete examples.
98
+ ## Documentation
99
+
100
+ For more detailed information, check out the [full documentation](https://model-bakery.readthedocs.io/).
109
101
 
110
102
  ## Contributing
111
103
 
112
- Detailed info [here](https://github.com/model-bakers/model_bakery/blob/main/CONTRIBUTING.md).
104
+ As an open-source project, Model Bakery welcomes contributions of many forms:
105
+
106
+ - Code patches
107
+ - Documentation improvements
108
+ - Bug reports
109
+
110
+ Take a look at our [contribution guidelines](CONTRIBUTING.md) for instructions
111
+ on how to set up your local environment.
113
112
 
114
113
  ## Maintainers
115
114
 
116
- - [Bernardo Fontes](https://github.com/berinhard/)
117
- - [Rustem Saiargaliev](https://github.com/amureki/)
118
- - [Tim Klein](https://github.com/timjklein36)
115
+ - [Bernardo Fontes](https://github.com/berinhard/)
116
+ - [Rustem Saiargaliev](https://github.com/amureki/)
117
+ - [Tim Klein](https://github.com/timjklein36)
119
118
 
120
119
  ## Creator
121
120
 
122
- - [Vanderson Mota](https://github.com/vandersonmota/)
121
+ - [Vanderson Mota](https://github.com/vandersonmota/)
122
+
123
+ ## License
124
+
125
+ Model Bakery is licensed under the MIT License.
126
+ See the [LICENSE](LICENSE) file for more information.
@@ -1,7 +1,7 @@
1
- model_bakery/__about__.py,sha256=5kgpbRZNZ0S3xTW7W-SYXeJdcA29AHOdGGCQhbEDGaU,23
1
+ model_bakery/__about__.py,sha256=qHrI4jqPIWHgrFaoVWc3nit8kNWAevyXviTPQ2Gl1bk,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=NjF__SdtxetVTN5Vc8PI2vek3PC5APxcPc6JB8hj_cw,31150
4
+ model_bakery/baker.py,sha256=szg16X-EoNqm9Qb-hAaVS66KOCygcPRtN7pVPM5yZno,31321
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
@@ -13,7 +13,7 @@ model_bakery/random_gen.py,sha256=3rvZCg5px6NOY1Q3fHSqw51BY6iQfCmOoRX4SsCOp6U,10
13
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.3.dist-info/METADATA,sha256=U1BlLchIR4sBgWtu5SKRi-ZnROYL_X8ZnkbfTXi0A6k,4406
17
- model_bakery-1.20.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- model_bakery-1.20.3.dist-info/licenses/LICENSE,sha256=kCwHls7z8Y7NyZCmdnV1qLSdLrQ8bHrXLji5HOasgUc,611
19
- model_bakery-1.20.3.dist-info/RECORD,,
16
+ model_bakery-1.20.5.dist-info/METADATA,sha256=eilO6E_BZcrQAgHF1VLxPlViJWA_hL2gaItOBVTF4yM,4665
17
+ model_bakery-1.20.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ model_bakery-1.20.5.dist-info/licenses/LICENSE,sha256=kCwHls7z8Y7NyZCmdnV1qLSdLrQ8bHrXLji5HOasgUc,611
19
+ model_bakery-1.20.5.dist-info/RECORD,,