Permalink
Browse files

Simplified the readme to point to RTD

  • Loading branch information...
1 parent ea3aa73 commit 0afb494232ebfae108144fbd1d3da3fdf31c7e24 @d0ugal d0ugal committed Nov 25, 2011
Showing with 1 addition and 62 deletions.
  1. +1 −62 README.rst
View
@@ -4,65 +4,4 @@ Django urlmiddleware
This app allows you to define middleware in your Django project based on url
configurations rather than adding middleware globally to every single request.
-
-Why?
-========================================
-
-Adding middleware globally is not always a good thing. You may only want it
-to take effect on certain areas in your website. Third party apps can also
-then include their middleware definitions in the url.py file and remove the
-need for you to modify global settings.
-
-
-Quick Start
-========================================
-
-Install urlmiddleware::
-
- pip install urlmiddleware
-
-There is no need to add it to your installed apps, however, you do need to
-register one global middleware class that will then control the url based
-middleware::
-
- MIDDLEWARE_CLASSES = (
- # ...
- # add urlmiddleware after all other middleware.
- 'urlmiddleware.URLMiddleware',
- )
-
-Start adding middleware to your project in your url.py files below your normal
-url definitions::
-
- middlewarepatterns = patterns('',
- url(r'^myapp/', MyMiddleWareClass),
- )
-
-A common example is using this technique to add login required to whole sub
-sections of your url tree. First you need to create a LoginRequiredMiddleware::
-
- from django.conf import settings
- from django.contrib.auth.views import login
- from django.http import HttpResponseRedirect
-
- class LoginRequiredMiddleware(object):
-
- def process_request(self, request):
-
- login_path = settings.LOGIN_URL
-
- if request.path != login_path and request.user.is_anonymous():
- if request.POST:
- return login(request)
- else:
- return HttpResponseRedirect('%s?next=%s' % (login_path, request.path))
-
-Then in your urls.py file::
-
- from myapp.middleware import LoginRequiredMiddleware
-
- middlewarepatterns = patterns('',
- url(r'^accounts/', LoginRequiredMiddleware),
- )
-
-Done!
+See http://urlmiddleware.readthedocs.org/ for further documentation.

0 comments on commit 0afb494

Please sign in to comment.