Tobias Dacoir
2015-01-20 21:26:01 UTC
I'm using django-contact-form which allows me to subclass it and add custom
fields to it. However all my added fields will appear at the bottom. I even
tried overwriting the original fields but still the order they appear is
wrong. How can I control this? I tried searching for an answer, but only
found ModelForm info that didn't work as the parent just inherits from
forms.Form and is not a ModelForm.
Parent Class cound be found here:
https://bitbucket.org/ubernostrum/django-contact-form/src/4b7d2fa20c1d01568fb7c4c800155378e176923b/contact_form/forms.py?at=default
My overwritten class:
class CustomContactForm(ContactForm):
REASON = (
('support', 'Support'),
('feedback','Feedback'),
)
reason = forms.ChoiceField(choices=REASON, label='Reason')
name = forms.CharField(max_length=100,
label=u'Your name')
email = forms.EmailField(max_length=200,
label=u'Your email address')
body = forms.CharField(widget=forms.Textarea,
label=u'Your message')
and my template:
{% extends 'base.html' %}
{% block body_block %}
<h2>Contact Form</h2>
<p>To send us a message fill out the below form.</p>
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit">
</form>
{% endblock %}
fields to it. However all my added fields will appear at the bottom. I even
tried overwriting the original fields but still the order they appear is
wrong. How can I control this? I tried searching for an answer, but only
found ModelForm info that didn't work as the parent just inherits from
forms.Form and is not a ModelForm.
Parent Class cound be found here:
https://bitbucket.org/ubernostrum/django-contact-form/src/4b7d2fa20c1d01568fb7c4c800155378e176923b/contact_form/forms.py?at=default
My overwritten class:
class CustomContactForm(ContactForm):
REASON = (
('support', 'Support'),
('feedback','Feedback'),
)
reason = forms.ChoiceField(choices=REASON, label='Reason')
name = forms.CharField(max_length=100,
label=u'Your name')
email = forms.EmailField(max_length=200,
label=u'Your email address')
body = forms.CharField(widget=forms.Textarea,
label=u'Your message')
and my template:
{% extends 'base.html' %}
{% block body_block %}
<h2>Contact Form</h2>
<p>To send us a message fill out the below form.</p>
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit">
</form>
{% endblock %}
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/725a9615-1d66-430a-8dbd-c7b1e70a7920%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/725a9615-1d66-430a-8dbd-c7b1e70a7920%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.