问题
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