Browse files

[1.2.X] Fixed #14775 -- Backports the changes in [13772], which docum…

…ented an undocumented feature from 1.0. Thanks to jweyrich for the report, and timo and leovitch for the patch (again).

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
Gabriel Hurley
Gabriel Hurley committed Nov 29, 2010
1 parent a647d0b commit 3c951d94b66433244b31c6ab49e53f1b608c0b6e
Showing with 39 additions and 3 deletions.
  1. +2 −0 docs/howto/deployment/modpython.txt
  2. +18 −3 docs/ref/request-response.txt
  3. +19 −0 docs/topics/http/urls.txt
@@ -1,3 +1,5 @@
+.. _howto-deployment-modpython:
How to use Django with Apache and mod_python
@@ -30,10 +30,25 @@ All attributes except ``session`` should be considered read-only.
.. attribute:: HttpRequest.path
- A string representing the full path to the requested page, not including
- the domain.
+ A string representing the full path to the requested page, not including
+ the domain.
- Example: ``"/music/bands/the_beatles/"``
+ Example: ``"/music/bands/the_beatles/"``
+.. attribute:: HttpRequest.path_info
+ Under some web server configurations, the portion of the URL after the host
+ name is split up into a script prefix portion and a path info portion
+ (this happens, for example, when using the ``django.root`` option
+ with the :ref:`modpython handler from Apache <howto-deployment-modpython>`).
+ The ``path_info`` attribute always contains the path info portion of the
+ path, no matter what web server is being used. Using this instead of
+ attr:`~HttpRequest.path` can make your code much easier to move between test
+ and deployment servers.
+ For example, if the ``django.root`` for your application is set to
+ ``"/minfo"``, then ``path`` might be ``"/minfo/music/bands/the_beatles/"``
+ and ``path_info`` would be ``"/music/bands/the_beatles/"``.
.. attribute:: HttpRequest.method
@@ -869,3 +869,22 @@ permalink()
The :func:`django.db.models.permalink` decorator is useful for writing short
methods that return a full URL path. For example, a model's
``get_absolute_url()`` method. See :func:`django.db.models.permalink` for more.
+.. function:: get_script_prefix()
+.. versionadded:: 1.0
+Normally, you should always use :func:`~django.core.urlresolvers.reverse` or
+:func:`~django.db.models.permalink` to define URLs within your application.
+However, if your application constructs part of the URL hierarchy itself, you
+may occasionally need to generate URLs. In that case, you need to be able to
+find the base URL of the Django project within its web server
+(normally, :func:`~django.core.urlresolvers.reverse` takes care of this for
+you). In that case, you can call ``get_script_prefix()``, which will return the
+script prefix portion of the URL for your Django project. If your Django
+project is at the root of its webserver, this is always ``"/"``, but it can be
+changed, for instance by using ``django.root`` (see :ref:`How to use
+Django with Apache and mod_python <howto-deployment-modpython>`).

0 comments on commit 3c951d9

Please sign in to comment.