diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2010-09-12 19:44:19 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2010-09-12 19:44:19 +0000 |
| commit | 030c97b119bea450cc4e1f289a95e91aa664221c (patch) | |
| tree | 3fdaada3057db89ae1e7e33c0e8a3d889b2240d7 /docs/topics | |
| parent | 7bb6abed129015ad447bd78506698f34c4d8273b (diff) | |
Documented how to manually piece together URLs with get_script_name().
Thanks to timo and leovitch for the patch. Fixed #10328.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13772 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/http/urls.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index 1ea991959b..1f499909ee 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -926,3 +926,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. + +get_script_prefix() +------------------- + +.. 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>`). |
