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
I never found a good snippet or tutorial to get the app_list (in django.admin) on other pages except the index page. So i started asking on irc j00bar has given me a very nice answer, but first i didn't know what to do with it till now.
Anyways this snippet is very handy for the people who wants this but don't know how to get it.
This is special made for the django version 1.1
Installation is quite easy, it is a context processor, so download this file put anywhere in your project, i got it in a app called cms_theme (theme and template related stuff.) and put the location in your settings.py file, example:
`TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'****cms.cms_themes.context_processors.theme',
'****cms.cms_themes.context_processors.applist',
)`
The '****' stuff is nothing, i replaced my company name with it.
Of course you may put the context processor anywhere else, that is your choice.
Good luck!
Alexander
- django
- models
- admin
- python
- applications
- app_list
- app-models