2012-12-11 16 views
5

tworzę tabelę z formularza:formularz Django as_table nowy wiersz

<form method="post" action=".">{% csrf_token %} 
    {{ form.as_table }} 
    <input type="submit" value="register" /> 
</form> 

w moim forms.py mam

class RegistrationForm(forms.Form): 
    username = forms.CharField(label=u'Username', max_length=30) 
    first_name = forms.CharField(label=u'First Name', max_length=30) 
    last_name = forms.CharField(label=u'Last Name', max_length=30) 
    email = forms.EmailField(label=u'Email') 
    password1 = forms.CharField(
           label=u'Password', 
           widget=forms.PasswordInput() 
           ) 
    password2 = forms.CharField(
           label=u'Password (Again)', 
           widget=forms.PasswordInput() 
           ) 

Problemem jest to, że każde pole jest wyświetlane w jednym rzędzie. jak mogę mieć różne wiersze dla wszystkich pól?

Odpowiedz

15

{{form.as_table}} powraca tylko <tr>...</tr> Trzeba by wyraźnie umieścić <table></table> owijkę wokół

Można odczytać documentation here

Powiązane problemy