Django - 具有控制数据的错误模型 [英] Django - Error models with control data
问题描述
我正在编写models.py文件,我需要一些控件来执行某些字段的自动编译。
I'm working on writing the models.py file, and I need some controls to perform the automatic compilation of some fields.
MOTIVOINGRESSO = (
(u'sequestro ', u'sequestro'),
(u'fermo ', u'fermo'),
(u'confisca final ', u'confisca final'),
(u'cambio custodian ', u'cambio custodian'),
)
motivo_ingresso = models.CharField (max_length = 50, choices = MOTIVOINGRESSO)
FERMO =(
(u'30',u'30'),
(u'60',u'60'),
(u'90',u'90'),
(u'180',u'180'),
(u'1 month',u'1 month'),
(u'3个月,'u'3个月'),
(u'indeterminato',u'indeterminato'),
)
durata_in_giorni_del_fermo = models.CharField(max_length = 20,选择= STOPPED,空白=真)
FERMO = ( (u'30 ', u'30'), (u'60 ', u'60'), (u'90 ', u'90'), (u'180 ', u'180'), (u'1 month ', u'1 month'), (u'3 months, 'u'3 months'), (u'indeterminato ', u'indeterminato'), ) durata_in_giorni_del_fermo = models.CharField (max_length = 20, choices = STOPPED, blank = True)
如果管理员选择点击 sequestro ,在 durata_in_giorni_del_fermo
将自动选择 indeterminato 。
我应该报告输入的值吗?或者机器周期如果在模型中?
If the administrator the choice click 'sequestro', in durata_in_giorni_del_fermo
will automatically selected 'indeterminato'.
Should I report the values entered? or machine cycles if within the models?
任何想法?
推荐答案
如果您将通过模板中的 Jquery
执行此操作,它非常简单。我不知道,这可以在 models.py
中进行。以下链接与您的问题非常相关。
Its very easy if you will do it through Jquery
in template. I don't know, this can be possible in models.py
. Below links are much relevant to your question.
- How to implement two dropdowns dependent on each other using Django and jQuery
- Dynamic select fields with JQuery and django
希望在以上内容之后,您将了解到有关ajax和jquery的想法链接:)
Hoping you will got the idea about ajax and Jquery after following above links :)
这篇关于Django - 具有控制数据的错误模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!