Django,表格无法提交

时间:2016-08-05 07:47:26

标签: django django-forms

我创建了表单,但我无法使用post方法提交它。我使用通用视图

当我尝试提交时,此链接显示'?csrfmiddlewaretoken = 4u6glHHJVueXItlN ...'

这是我的代码:

表单模板:

   <form action="" method="post" class="form-inline">
        {% csrf_token %}
  <div class="modal-body clearfix">

      {% include 'words/word_form.html' %}

  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
    <button type="submit" class="btn btn-primary">Save changes</button>
  </div>
        </form>

通用视图:

class Create_Word(generic.CreateView):
   model=Word
   fields=['name','translation']
   template_name = "words/list_all.html"

这是word_form模板:

{%load extra%}




{% for field in form %}
    <div class="form-group ">

    <div class="col-sm-10">
        <span class="text-danger-small">{{ field.errors }}</span>

    </div>

    <label class="control-label col-sm-2 m-l-1  ">{{ field.label_tag }}</label>
    <div class= "col-sm-9 m-b-1">
        {{ field | addcss:"form-control" }}

    </div>

  {% endfor %}

0 个答案:

没有答案