1
0
mirror of https://github.com/django/django.git synced 2025-04-09 07:56:43 +00:00

Merge branch 'django:main' into skushagra-patch-1-issue-35119

This commit is contained in:
Kushagra S 2024-01-20 22:20:29 +05:30 committed by GitHub
commit e9bc91d907
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 5 deletions

View File

@ -1,3 +1,3 @@
<svg width="13" height="13" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
<path fill="#70bf2b" d="M1600 796v192q0 40-28 68t-68 28h-416v416q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-416h-416q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h416v-416q0-40 28-68t68-28h192q40 0 68 28t28 68v416h416q40 0 68 28t28 68z"/>
<path fill="#5fa225" d="M1600 796v192q0 40-28 68t-68 28h-416v416q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-416h-416q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h416v-416q0-40 28-68t68-28h192q40 0 68 28t28 68v416h416q40 0 68 28t28 68z"/>
</svg>

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View File

@ -1,3 +1,3 @@
<svg width="13" height="13" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
<path fill="#efb80b" d="M491 1536l91-91-235-235-91 91v107h128v128h107zm523-928q0-22-22-22-10 0-17 7l-542 542q-7 7-7 17 0 22 22 22 10 0 17-7l542-542q7-7 7-17zm-54-192l416 416-832 832h-416v-416zm683 96q0 53-37 90l-166 166-416-416 166-165q36-38 90-38 53 0 91 38l235 234q37 39 37 91z"/>
<path fill="#b48c08" d="M491 1536l91-91-235-235-91 91v107h128v128h107zm523-928q0-22-22-22-10 0-17 7l-542 542q-7 7-7 17 0 22 22 22 10 0 17-7l542-542q7-7 7-17zm-54-192l416 416-832 832h-416v-416zm683 96q0 53-37 90l-166 166-416-416 166-165q36-38 90-38 53 0 91 38l235 234q37 39 37 91z"/>
</svg>

Before

Width:  |  Height:  |  Size: 380 B

After

Width:  |  Height:  |  Size: 380 B

View File

@ -1628,7 +1628,7 @@ class Model(AltersData, metaclass=ModelBase):
errors = {}
for f in self._meta.fields:
if f.name in exclude:
if f.name in exclude or f.generated:
continue
# Skip validation for empty fields with blank=True. The developer
# is responsible for making sure they have a valid value.

View File

@ -15,3 +15,6 @@ Bugfixes
* Fixed a regression in Django 5.0 where links in the admin had an incorrect
color (:ticket:`35121`).
* Fixed a bug in Django 5.0 that caused a crash of ``Model.full_clean()`` on
models with a ``GeneratedField`` (:ticket:`35127`).

View File

@ -502,7 +502,7 @@ class GeneratedModel(models.Model):
output_field=models.IntegerField(),
db_persist=True,
)
fk = models.ForeignKey(Foo, on_delete=models.CASCADE, null=True)
fk = models.ForeignKey(Foo, on_delete=models.CASCADE, null=True, blank=True)
class Meta:
required_db_features = {"supports_stored_generated_columns"}
@ -516,7 +516,7 @@ class GeneratedModelVirtual(models.Model):
output_field=models.IntegerField(),
db_persist=False,
)
fk = models.ForeignKey(Foo, on_delete=models.CASCADE, null=True)
fk = models.ForeignKey(Foo, on_delete=models.CASCADE, null=True, blank=True)
class Meta:
required_db_features = {"supports_virtual_generated_columns"}

View File

@ -168,6 +168,14 @@ class GeneratedFieldTestMixin:
with self.assertRaisesMessage(AttributeError, msg):
m.field
def test_full_clean(self):
m = self.base_model(a=1, b=2)
# full_clean() ignores GeneratedFields.
m.full_clean()
m.save()
m = self._refresh_if_needed(m)
self.assertEqual(m.field, 3)
def test_create(self):
m = self.base_model.objects.create(a=1, b=2)
m = self._refresh_if_needed(m)