Try

def __init__(self, *args, **kwargs):
        super(CustomContactForm, self).__init__(*args, **kwargs)
        self.fields.keyOrder = ['name', 'reason', 'email', 'body']


On Tuesday, January 20, 2015 at 11:26:01 PM UTC+2, Tobias Dacoir wrote:
>
> 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 %}
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/6b0ae083-59df-48d6-bc29-f6f9ae6878af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to