Django的1.5给错误405的简单形式(Django 1.5 giving error 405

2019-10-16 22:41发布

我为包括验证组的形式。 但是,当我将它张贴我得到了一个空白页面(网址/组/)与终端的错误:“POST / grupos / HTTP / 1.1” 405 0这是太奇怪了,当我刷新我看到组的列表,没有什么补充。

=== urls.py

    url(r'^groups/$', login_required(TemplateUtilsListView.as_view(model=Group)), name='group_list'),
url(r'^groups/add$', login_required(CreateView.as_view(model=Group, form_class=GroupForm, template_name='generic_insert.html')), name='group_create'),

=== forms.py ===

class GroupForm(forms.ModelForm):
class Meta:
    model = Group

=== generic_insert.html ===

<form enctype="multipart/form-data" method="post" action=".">
{% if form.visible_fields %}
{% for field in form.visible_fields %}
<p>
    <label {% if field.field.required %}class="required-field"{% endif %}>{{ field.label }}:</label> 
    {{ field }}
        {% if field.errors %}
        <span class="error-list">{% for error in field.errors %}{{ error }}{% endfor %}</span>
        {% endif %}
        {% if field.help_text %}<img src="{{ MEDIA_URL }}images/help-icon.png" class="help-icon" title="{{ field.help_text }}">{% endif %}
</p>
{% endfor %}
{% endif %}
<p><input type="submit" class="button" value="{% trans 'Salvar' %}" /></p>
</form>
文章来源: Django 1.5 giving error 405 for simple form