Django 1.5 giving error 405 for simple form

走远了吗. 提交于 2020-01-16 00:46:24

问题


I made a form for including Auth Groups. But when I post it I get a blank page (url /groups/) with an Error on terminal: "POST /grupos/ HTTP/1.1" 405 0 This is so weird, when I give refresh I see the list of groups, with nothing added.

=== 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>

来源:https://stackoverflow.com/questions/11316709/django-1-5-giving-error-405-for-simple-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!