Django 1.5为简单形式提供错误405

时间:2012-07-03 18:11:09

标签: django authentication http-status-code-405 create-view

我制作了一个包含Auth Groups的表单。但是当我发布它时,我得到一个空白页面(url / groups /),终端上有错误:" 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>

0 个答案:

没有答案