百度 但是今后,对一个个新进入城市的家庭而言,如何充分保障其就业、就学等需要,如何有效满足其住房、就医、养老等需求,社区服务要如何跟上?值得仔细思量。

Opened 5个月 ago

Closed 5个月 ago

#36212 closed New feature (wontfix)

How about providing type safe access to form field data?

汇报人: Justin Black 属主:
组件: Forms 版本: 5.1
严重性: Normal 关键词: form, field
抄送: Triage Stage: Unreviewed
Has patch: Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

描述 (最后由 Justin Black 修改)

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.

变更历史 (2)

comment:1 by Justin Black, 5个月 ago

描述: 修改了 (差异)

comment:2 by Sarah Boyce, 5个月 ago

处理结果: wontfix
状态: newclosed
类型: UncategorizedNew feature
组件: UncategorizedForms

As this is requesting a new feature for Django. The recommended path forward is to first propose and discuss the idea with the community and gain consensus. To do that, please consider starting a new conversation on the ?Django Forum, where you'll reach a broader audience and receive additional feedback.

I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to ?the documented guidelines for requesting features.

I also recommend you look for similar type conversations and try to incorporate or summarize opinions from these.

Note: See TracTickets for help on using tickets.
Back to Top