Add admin edit form buttons (work with django 1.6)
I can't find any workable solution, so I wrote it. (Checked it on Django 1.6)
- admin
- form
- edit
- button
I can't find any workable solution, so I wrote it. (Checked it on Django 1.6)
Difference from standard Django 1.4 implementation is just structure of list. In django `<input>` elements are *wrapped* by their labels, and look like this:: <ul> <li><label><input/> Label 1</label> <li><label><input/> Label 2</label> </ul> This widget puts labels *after* input elements:: <ul class="form-button-radio"> <li><input/> <label>Label 1</label> <li><input/> <label>Label 2</label> </ul> It makes possible to define style for both inputs and labels, hiding inputs and making labels look like pressable buttons. No javascript needed, just CSS (see docstring). To auto-submit the form when pressing a button, JQuery can be added:: <script> $(document).ready(function() { $('ul.form-button-radio input[type="radio"]').change(function() { $(this).parents('form').submit(); }); }); </script>
See [link](http://www.djangosnippets.org/snippets/2005/) for description. Note: Requires Django 1.2.
Add a Save and view next button to your admin change form. Put the code at [link](http://www.djangosnippets.org/snippets/2006/) in a file called myapp/templates/admin/myapp/change_form.html Note: Requires Django 1.2.
This is an improvement on other ButtonAdmin implementations. A few features : It allows you to specify whether button appears on change form or change list; whether the form is to be saved before the resulting function is called; whether the button should be displayed Look at the bottom of the snippet for usage. And make sure you admin urls are enabled using (r'^admin/', include(admin.site.urls)) instead of the old method
If you want all the objects in your models' admin interface to have a direct link to their databrowse page (just like the *history* link).. follow these steps: 1) copy the *change_form.html* admin template in mytemplates/admin/ 2) edit *change_form.html* by adding this code right next to (before or after) the following line (=the history button markup): `<li><a href="history/" class="historylink">History</a></li>` 3) Make sure that all of you models are registered with [databrowse](http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/) That's it. Obviously if you don't want ALL the models to have this link, you should use a different recipe, for example this one: [http://www.djangosnippets.org/snippets/1016/](http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/)
6 snippets posted so far.