django-adminwidgetswap
===============
adminwidgetswap is used for dynamically swapping out widgets from django's generated admin.
This allows applications to be packaged generically without the need for WYSIWYG dependencies editors- giving the application consumer the freedom to chose admin widgets without modifying original app source.
Author
======
[David Davis](http://www.davisd.com)
(http://www.davisd.com)
[dynamically change django admin widets at runtime (django-adminwidgetswap) blog post](http://www.davisd.com/blog/2010/04/17/dynamically-change-django-admin-widgets-at-runtime/)
Usage
===============
To change a widget in django's admin, just put adminwidgetswap.py on the python path, import adminwidgetswap.py and use:
adminwidgetswap.swap_model_field(model, field, widget)
...to change a widget for a direct model admin's field
---
adminwidgetswap.swap_model_inline_field(model, field, widget)
...to change widgets for inlines of a specific model and field
---
adminwidgetswap.swap_model_and_inline_fields(model, field, widget)
...to change both the widget for the direct model admin's field as well as all inline usages for the model and field
---
I usually have a project-level application called website, and I put this initialization code inside the website app's __init__.py
Usage - parameters
===============
model is the Model class
(eg. models.GalleryImage)
field is the field name you're looking to swap
(eg. 'image')
widget is the widget you're going to swap for
(eg. widgetlibrary.ThumbnailWidget())
- admin
- widgets
- abstraction
Based on http://www.djangosnippets.org/snippets/592/, a simplified recurse template tag that will explore dict and list objects. Useful and straightforward for JSON documents (for instance from couchdb :p).
Actual usage example:
{% recursedict mydictionary %}
<ul>
{% loop %}
<li>{% if key %}<b>{{ key }}</b>: {% endif %}{% value %}</li>
{% endloop %}
</ul>
{% endrecurse %}
The main tag syntax is "recursedict var" where var is your dictionary name.
The "key" property will contain the current key, or None if the current value comes from a list (in other words the list (a, b, c) is handled like a very hypothetical {None: a, None: b, None: c} dictionary.)
{% value %} will output the current value, or recurse if the value is a list, tuple or dict.
- template
- templatetag
- json
- dict
- resurse
Allows you to dynamically maintain a local_constants.py file from a migration tool like South. Example of usage:
set_constant('/home/projects/sample/local_constants.py', 'STAMP_MW_ID', 42, 'Set from sample.0007_add_constants.py')
More more information, see [Allows you to dynamically maintain a local_constants.py file from a migration tool like South. Example of usage:
set_constant('/home/projects/sample/local_constants.py', 'STAMP_MW_ID', 42, 'Set from sample.0007_add_constants.py')
More more information, see [http://menendez.com/blog/maintain-contants-through-south-data-migration/](http://menendez.com/blog/maintain-contants-through-south-data-migration/).