cbgv UpdateView和modelform,html表单不提交数据

时间:2013-11-14 13:29:37

标签: django forms django-class-based-views

在django 1.6中,下面的模板/表单在我点击“提交”按钮后没有提交帖子请求,但是当我运行django 1.5.3时这一切都有效! 我缺少什么?

这是我简化的摘录:

models.py

class Codici(models.Model):
    PIECES = 'pcs'
    GRAM = 'g'
    METRE = 'm'
    SI_UNITS_CHOICES = (
        (PIECES, 'pezzi'),
        (GRAM, 'grammi'),
        (METRE, 'metri'),
    )
    codice = models.CharField(max_length=120, unique=True)
    descrizione = models.TextField(blank=True)
    stock = models.BigIntegerField(default=0)
    fornitori = models.ManyToManyField(Fornitori)
    si_unit = models.CharField(max_length=3,
                                       choices=SI_UNITS_CHOICES,
                                       default=PIECES)

    def get_absolute_url(self):
        return reverse('update', kwargs={'pk': self.pk})

urls.py

url(r'^codici/update/(?P<pk>\d+)/$',
    CodiceUpdateView.as_view(),
    name='update'),

forms.py

class CodiceForm(ModelForm):
    class Meta:
        model = Codici
        fields = ('codice', 'descrizione', 'stock', 'si_unit',
                  'fornitori')

views.py

class CodiceUpdateView(UpdateView):
    model = Codici
    form_class = CodiceForm

app / codice_form.html(模板)

{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% block content %}
    <form action="" method="post">{% csrf_token %}
      {{ form|crispy }}
      <button type="submit" value="Update">Save</button>
    </form>
{% endblock %}

1 个答案:

答案 0 :(得分:0)

这是angularjs干扰我的表单验证......