Django Hidden Fields

Quick shortcut for including hidden fields in your forms:

forms.py

class SomeForm(forms.Form):
hidden = forms.CharField(required=False, max_length=50, widget=forms.HiddenInput())

view raw
forms.py
hosted with ❤ by GitHub

template.html

{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}

view raw
template.html
hosted with ❤ by GitHub

Now you don’t have to worry about each and every hidden field.

One thought on “Django Hidden Fields”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s