mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #20522 - Allowed use of partially validated object in ModelAdmin.add_view formset validation.
Updated ModelAdmin to use form.instance when passing parent model to child inlines for add_view. There is effectively no change in the change_view since the previously passed 'obj' is the same as form.instance. Thanks to meshy for report, and EvilDMP and timo for review.
This commit is contained in:
committed by
Tim Graham
parent
1c7a83ee8e
commit
c74504c2dd
@@ -712,6 +712,26 @@ class Choice(models.Model):
|
||||
choices=((1, 'Yes'), (0, 'No'), (None, 'No opinion')))
|
||||
|
||||
|
||||
class ParentWithDependentChildren(models.Model):
|
||||
"""
|
||||
Issue #20522
|
||||
Model where the validation of child foreign-key relationships depends
|
||||
on validation of the parent
|
||||
"""
|
||||
some_required_info = models.PositiveIntegerField()
|
||||
family_name = models.CharField(max_length=255, blank=False)
|
||||
|
||||
|
||||
class DependentChild(models.Model):
|
||||
"""
|
||||
Issue #20522
|
||||
Model that depends on validation of the parent class for one of its
|
||||
fields to validate during clean
|
||||
"""
|
||||
parent = models.ForeignKey(ParentWithDependentChildren)
|
||||
family_name = models.CharField(max_length=255)
|
||||
|
||||
|
||||
class _Manager(models.Manager):
|
||||
def get_queryset(self):
|
||||
return super(_Manager, self).get_queryset().filter(pk__gt=1)
|
||||
|
||||
Reference in New Issue
Block a user