Get only one field from django forms in a template

I have one form:

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

How can I only place an email field in my template? I tried this:

 {{ form.fields.email }} 

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

+4
source share
2 answers

You can simply use:

 {{ form.email }} 
+8
source

You do not need to use fields . Using:

 {{ form.email }} 
+1
source

Source: https://habr.com/ru/post/1447843/


All Articles