Skip to content Skip to sidebar Skip to footer

Accessing Individual Form Fields In Django Template

I want to access the individual element of the form... here is the code: Models.py class GatewayDetails(models.Model): gateway_id = models.IntegerField(primary_key=True) ga

Solution 1:

You can do:

{% for form_field in add_gateway_details_form %}
    {{ form_field }}
{% endfor %}

You can also access a field like:

{{ add_gateway_details_form.gateway_name }}

This is explained in detail in the documentation on forms and templates.

Solution 2:

Actually, outside the form you probably need this:

{{some_form.some_field.value}}

Post a Comment for "Accessing Individual Form Fields In Django Template"