diff options
Diffstat (limited to 'tests/modeltests')
| -rw-r--r-- | tests/modeltests/model_formsets/models.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/modeltests/model_formsets/models.py b/tests/modeltests/model_formsets/models.py index d8cbe34b94..f30b2125e2 100644 --- a/tests/modeltests/model_formsets/models.py +++ b/tests/modeltests/model_formsets/models.py @@ -108,6 +108,10 @@ class Price(models.Model): class MexicanRestaurant(Restaurant): serves_tacos = models.BooleanField() +class ClassyMexicanRestaurant(MexicanRestaurant): + restaurant = models.OneToOneField(MexicanRestaurant, parent_link=True, primary_key=True) + tacos_are_yummy = models.BooleanField() + # models for testing unique_together validation when a fk is involved and # using inlineformset_factory. class Repository(models.Model): @@ -934,4 +938,9 @@ True >>> formset.get_queryset() [<Player: Bobby>] +# a formset for a Model that has a custom primary key that still needs to be +# added to the formset automatically +>>> FormSet = modelformset_factory(ClassyMexicanRestaurant, fields=["tacos_are_yummy"]) +>>> sorted(FormSet().forms[0].fields.keys()) +['restaurant', 'tacos_are_yummy'] """} |
