Django admin clear button for form
1 answer
In your templates directory create an admin folder, in that create a file submit_line.html
, paste this code there (this is actually the original submit_line with the last added <input...
:
{% load i18n %}
<div class="submit-row" {% if is_popup %}style="overflow: auto;"{% endif %}>
{% if show_save %}<input type="submit" value="{% trans 'Save' %}" class="default" name="_save" {{ onclick_attrib }}/>{% endif %}
{% if show_delete_link %}<p class="deletelink-box"><a href="delete/" class="deletelink">{% trans "Delete" %}</a></p>{% endif %}
{% if show_save_as_new %}<input type="submit" value="{% trans 'Save as new' %}" name="_saveasnew" {{ onclick_attrib }}/>{%endif%}
{% if show_save_and_add_another %}<input type="submit" value="{% trans 'Save and add another' %}" name="_addanother" {{ onclick_attrib }} />{% endif %}
{% if show_save_and_continue %}<input type="submit" value="{% trans 'Save and continue editing' %}" name="_continue" {{ onclick_attrib }}/>{% endif %}
<input type="reset" value="Reset form" />
</div>
Now that it does what you want, the Reset Form button will appear unclickable in some browsers (some effect is disabled). However, it will work. You can replace the input as well <button type="reset">Reset form</button>
, but I find it pretty ugly. Finally, you can also search for stylesheets to see which code works (it's like typing ['reset'] that's missing somewhere). But anyway, it works, have fun with it.
+2
a source to share