【问题标题】:Get the value from a placeholder to send it in the form django从占位符中获取值以 django 的形式发送
【发布时间】:2014-04-26 00:53:08
【问题描述】:

我在模型中使用了默认值

constitucional_64 = models.CharField(max_length=500, null=True,blank=True,default='negado')

问题是当我点击它时我需要从输入中删除值,我在我的 ModelForm 中使用占位符

class ExpedienteInicialform(ModelForm):
  class Meta:
    model = ExpedienteConsultaInicial
    widgets = {
        'constitucional_64': forms.TextInput(attrs={'placeholder': 'negado'}),
    }

但我需要获取值 'negado' 以将其发送到数据库,占位符工作正常,问题是我没有在 POST 中获取值。

【问题讨论】:

标签: python django forms models placeholder


【解决方案1】:

使用value,而不是placeholder

'constitucional_64': forms.TextInput(attrs={'value': 'negado'}),

【讨论】:

    猜你喜欢
    • 2012-10-03
    • 2018-01-25
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 2017-07-27
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多