Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get only one field from django forms in template

I have one form :

class FormLogin(forms.Form):
    email = forms.EmailField(max_length=150)
    name  = forms.CharField(max_length=20)

How can I put just email field in my template ? I tried this :

{{ form.fields.email }}

But it returns <django.forms.fields.CharField object at 0x00000000043BCEB8>.

like image 289
rayashi Avatar asked Nov 23 '12 00:11

rayashi


2 Answers

You can just use:

{{ form.email }}
like image 64
Timmy O'Mahony Avatar answered Sep 30 '22 03:09

Timmy O'Mahony


You don't need to use fields. Use:

{{ form.email }}
like image 43
Joyfulgrind Avatar answered Sep 30 '22 01:09

Joyfulgrind