#36212: How about providing type safe access to form field data?
------------------------------+-----------------------------------------
     Reporter:  Justin Black  |                     Type:  Uncategorized
       Status:  new           |                Component:  Uncategorized
      Version:  5.1           |                 Severity:  Normal
     Keywords:  form, field   |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+-----------------------------------------
 Right now only cleaned data is acessed in a dict in python.
 This means that type hcecking code does not know the type of that dict
 unless it is described as a typeddict.
 How about providing type safe access to form field data?

 ```
 class FormOptions(forms.Form):
     prompt = forms.CharField(widget=forms.Textarea)
     n = forms.IntegerField(min_value=1, max_value=10, initial=1)

 form_options = FormOptions({'prompt': 'a', 'n': 2})
 ```

 one could access it as:
 form_options.prompt.cleaned_data
 or
 form_options.prompt

 This would allow code to access type safe values for a form in python.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36212>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701953692c123-eef23fc0-1256-4e87-9ea7-eb832b305872-000000%40eu-central-1.amazonses.com.

Reply via email to