So I tried to create a form in my views.py file, which when rendered in the template did not show. I tried to do this in the manage.py shell like this:
>>> from django import forms
>>> class Test(forms.Form):
... about = forms.CharField(max_length=250)
... animal = forms.CharField(max_length=50)
... email = forms.EmailField()
...
>>> form = Test()
>>> form.as_p
<bound method Test.as_p of <Test object at 0xa9e446c>>
>>>
As far as I’m aware, the form.as_p should give me the form, but instead it returns the output above. I assume what’s happening in the shell is what’s happening in my view and template. Forms do not render with bound data either.
Any idea what is causing this behavior? I believe I’ve followed the Django docs on forms closely.
as_pis a method, so if you want to use it in the interpreter, you should useas_p(). The method lookup and call are done automagically by the template renderer, so that’s why you don’t need the brackets in a template.