Reputation: 149
OrderedDict([('first_name', <django.forms.fields.CharField object at 0x7f9b5bed4c50>), ('last_name', <django.forms.fields.CharField object at 0x7f9b3b7abf50>), ('email', <django.forms.fields.EmailField object at 0x7f9b3b7abf10>)])
I am a new programmer in Python/Django, and I neeed a bit a of help.
I have this dictionnary, when I called self.fields
. I am trying to get access the value of email
with email = self.fields.get('email', False)
, which is supposed to be something like [email protected]
, but I got <django.forms.fields.EmailField object at 0x7f9b3b7abf10>
. Is it because the space is not used yet? Otherwise, how could I get the value of email
?
Upvotes: 1
Views: 69
Reputation: 3223
The correct way to get data from a form is to first call .is_valid()
, then look up the value in self.cleaned_data
, in this case, you'd do:
if self.is_valid():
email = self.cleaned_data['email']
For more information, see the docs.
Upvotes: 5