Django admin add custom button in change form depending on a form field value -
i have application overrides het django alter form. want alter submit buttons on bottom. underneath change_form.html in django app:
{% extends "admin/change_form.html" %} {% block submit_buttons_bottom %} ## add together buttons {% endblock %} the button want show/add depends on value of field in form names 'status'. how can value of field in template... something like:
{% if form.field.status == 'unresolved' %} <input type="submit" value="mark resolved" class="default" name="_save" /> {% endif %} update:
i'm not getting errors. there nil displayed.
looping through var 'adminform' me field need
{% fieldset in adminform %} {% line in fieldset %} {% field in line %} {% if field.field.name == 'status' %} status {{ field.field.name }} - {{ field.contents }} {% endif %} {% endfor %} {% endfor %} {% endfor %} but want access directly. something like:
{% if adminform.0.0.field.status == 'unresolved' %} <input type="submit" value="mark resolved" class="default" name="_save" /> {% endif %}
try changing if statement -
{% if adminform.status.value == 'unresolved' %} i'm guessing, think adminform variable form. have @ this section of docs see atributes of form fields.
django django-templates django-admin
No comments:
Post a Comment