Login

Tag "button"

Snippet List

Radio widget with labels after inputs

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>

  • widget
  • label
  • input
  • button
  • reorder
  • radio
  • radio button
Read More

Admin Save and view next button

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.

  • admin
  • view
  • save
  • button
  • next
  • 1.2
Read More

Button Admin

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

  • admin
  • button
Read More

Simple Admin-button linking to Databrowse

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/)

  • django
  • admin
  • databrowse
  • button
Read More

6 snippets posted so far.