0

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

这是我的简化片段:

模型.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})

网址.py

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

表格.py

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

视图.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 %}
4

1 回答 1

0

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

于 2013-11-14T16:55:17.980 回答