Django - Error models with control data

喜你入骨 提交于 2019-12-07 13:30:43

问题


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 months, 'u'3 months'), (u'indeterminato ', u'indeterminato'), ) durata_in_giorni_del_fermo = models.CharField (max_length = 20, choices = STOPPED, blank = True)

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?

Any Ideas?


回答1:


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.

  1. How to implement two dropdowns dependent on each other using Django and jQuery
  2. Dynamic select fields with JQuery and django

Hoping you will got the idea about ajax and Jquery after following above links :)



来源:https://stackoverflow.com/questions/11341768/django-error-models-with-control-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!