Hi all,

As part of our test process we have code that automatically fills in forms with dummy values to make them valid. It fills in all required fields.

This works well except for formsets. BaseModelFormSet.add_fields() adds a PK field to the form after it's created. It marks this field as not required:

    form.fields[self._pk_field.name] = ModelChoiceField(qs, initial=pk_value, 
required=False, widget=widget)
    <https://github.com/django/django/blob/master/django/forms/models.py#L805>

However it will blow up if editing an existing instance and this field isn't present, so in a sense it is required.

I know it's a very minor issue and I can easily work around it (however ugly that is), but would it logically make sense for this field to be required if pk is not None?

Cheers, Chris.
--
Aptivate | http://www.aptivate.org | Phone: +44 1223 967 838
Citylife House, Sturton Street, Cambridge, CB1 2QF, UK

Aptivate is a not-for-profit company registered in England and Wales
with company number 04980791.

--
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/alpine.OSX.2.00.1403191703550.13253%40chris-macbook.lan.
For more options, visit https://groups.google.com/d/optout.

Reply via email to