summaryrefslogtreecommitdiff
path: root/tests/admin_views/models.py
diff options
context:
space:
mode:
authorJay Leadbetter <jay.leadbetter@gmail.com>2013-11-14 19:26:19 -0700
committerTim Graham <timograham@gmail.com>2013-11-25 20:01:16 -0500
commitc74504c2dd21974571ab72805fbfc8d4d76ce151 (patch)
treedf8996aa78b584d2d467f06849d71a5b0205c685 /tests/admin_views/models.py
parent1c7a83ee8e3da431d9d21dae42da8f1f89973f7c (diff)
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.
Diffstat (limited to 'tests/admin_views/models.py')
-rw-r--r--tests/admin_views/models.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py
index e0e2a6fc08..b517530952 100644
--- a/tests/admin_views/models.py
+++ b/tests/admin_views/models.py
@@ -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)