I use a custom template to display my form:
...
<td>Username</td>
<td><input id="id_username" type="text" maxlength="30" name="username" tabindex="1"></td>
...
If I submit my registration form with (for example) a required field empty, django refresh the page and show me the error. The problem are the other fields (the correct ones). They’re reset and the previous data filled in is cleared. If instead of using a custom way to display a field I use {{ form.field }} it works fine and if there’s errors in the form, django fills the other correct fields.
How can I solve this?
You could try this:
forms.py
views.py
template myloginform.html
Edit:
To add it to the attrs dict as mentioned by Daniel above use:
uname = forms.CharField(max_length=20, widget=forms.TextInput(attrs={'tabindex':'1', 'class': 'myclass'}))