Answer the question
In order to leave comments, you need to log in
Django 405 Method Not Allowed?
I can't figure out what's going on:
models:
class Contact(models.Model):
name = models.CharField('Имя', max_length=30)
email = models.CharField('Email', max_length=40)
class ContactForm(ModelForm):
class Meta:
model = Contact
fields = ('name', 'email')
class ContactFormView(FormView):
form_class = ContactForm
template_name = 'contact.html'
success_url = '/'
def form_valid(self, form):
form.save()
username = form.cleaned_data['username']
email = form.cleaned_data['email']
contact = Contact.objects.create(username=username, email=email)
contact.save()
return HttpResponseRedirect(self.get_success_url())
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Запись на курс</h4>
</div>
<div class="modal-body">
<form method="post">
{% csrf_token %}
{{ my_form.as_p }}
<button class='' type="submit">Записаться</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
<button type="button" class="btn btn-primary">Сохранить изменения</button>
</div>
</div>
</div>
</div>
url(r'^contact-form/$', ContactFormView.as_view(), name='contact'),
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question