django-crequest

Middleware to make current request always available
Download

django-crequest Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Alireza Savand
  • Publisher web site:
  • https://github.com/Alir3z4/

django-crequest Tags


django-crequest Description

django-crequest is a Django app that will bring you current request object of your Django application from anywhere in your code.Installingdjango-crequest is available at http://pypi.python.org/pypi/django-crequest So it can be install it by pip: pyhton pip install django-crequestOr you can grab the latest version tarball and python setup.py installTo enable django-crequest in your project- Add 'crequest' to INSTALLED_APPS in your settings.py- Add 'crequest.middleware.CrequestMiddleware' to MIDDLEWARE_CLASSES after the authentication and session middleware.How to use itFirst import the crequest's middleware:from crequest.middleware import CrequestMiddlewareGet the current request ;):current_request = CrequestMiddleware.get_request()Done.Some info for some folksSet the current request in UnKnown situations:CrequestMiddleware.set_request(request)Return iam_request if there is no current request:CrequestMiddleware.get_request(iam_request)And finally delete:CrequestMiddleware.del_request()The middleware automatically sets/deletes the current request for HTTP requests. For other uses (management commands, scripts), you will need to do this yourself.Product's homepage


django-crequest Related Software