forked from danielfm/django-flash
-
Notifications
You must be signed in to change notification settings - Fork 0
Rails-like flash context support for Django
License
aparo/django-flash
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
django-flash ------------ http://github.com/danielfm/django-flash django-flash adds a Rails-like flash context support to Django. Installation ------------ The easiest way to install django-flash is via EasyInstall[1]. Follow these[2] instructions to install EasyInstall if you don't have it already. Then, execute the following command line to install the latest stable version of django-flash: $ sudo easy_install django-flash If you use Git and want to get the latest *development* version: $ git clone git://github.com/danielfm/django-flash.git $ cd django-flash $ sudo python setup.py install Or get the latest *development* version as a tarball: $ wget http://github.com/danielfm/django-flash/tarball/master $ tar zxf danielfm-django-flash-XXXXXXXXXXXXXXXX.tar.gz $ cd danielfm-django-flash-XXXXXXXXXXXXXXXX $ sudo python setup.py install Using django-flash ------------------ The first thing to do is plug django-flash to your Django project. To do this, open your project's 'settings.py' file and do the following changes: # ...some settings... TEMPLATE_CONTEXT_PROCESSORS = ( # other context processors... 'djangoflash.context_processors.flash', ) MIDDLEWARE_CLASSES = ( # ...other middleware classes... 'django.contrib.sessions.middleware.SessionMiddleware', 'djangoflash.middleware.FlashMiddleware', # ...more middleware classes... ) # ...more settings... After doing that all HttpRequest objects received by your views will have an extra attribute called 'flash' in which you can store the data you want to be available to the next request. Here goes an example on how to actually use the the flash context: # ...some views... def some_view(request): # ...do some work here... if success: # There are several ways to use the 'flash' context request.flash = 'Success' request.flash['some_key'] = MyObject() request.flash.some_key = ['an', 'array', 'here'] return HttpResponseRedirect('http://some/url/') # ...more views... Os dados que forem inseridos no contexto flash poderão ser acessados na próxima requisição. Por exemplo, o código abaixo mostra como acessar os dados do contexto flash a partir de um template HTML: Whatever you put in it will become available to the next request. For example, the code below shows how to access data stored in the 'flash' context from a HTML template: <html> <head>...</head> <body> {% if flash %} <div id="flash_message_panel"> {{ flash }} </div> {% endif %} </body> </html> Links ----- [1] EasyInstall - http://peak.telecommunity.com/DevCenter/EasyInstall [2] Setuptools - http://pypi.python.org/pypi/setuptools Authors ------- Name: Daniel Fernandes Martins <daniel.tritone@gmail.com> Company: Destaquenet Technology Solutions <http://www.destaquenet.com/> --EOF
About
Rails-like flash context support for Django
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Python 100.0%