Code

Ticket #10328: urls.diff

File urls.diff, 1.3 KB (added by leovitch, 5 years ago)

diff for docs/topics/http/urls.txt

Line 
1Index: docs/topics/http/urls.txt
2===================================================================
3--- docs/topics/http/urls.txt   (revision 9904)
4+++ docs/topics/http/urls.txt   (working copy)
5@@ -640,3 +640,28 @@
6 The :func:`django.db.models.permalink` decorator is useful for writing short
7 methods that return a full URL path. For example, a model's
8 ``get_absolute_url()`` method. See :func:`django.db.models.permalink` for more.
9+
10+get_script_prefix()
11+-------------------
12+
13+.. versionadded:: 1.0
14+
15+Normally, you should always use
16+:func:`~django.core.urlresolvers.reverse` or
17+:func:`~django.db.models.permalink` to define URLs
18+within your application.
19+However, if your application constructs
20+part of the URL hierarchy itself you may occasionally
21+need to generate URLs.
22+In that case, you need to be able to find the base URL
23+of the Django project within its web server
24+(normally, :func:`~django.core.urlresolvers.reverse`
25+takes care of this for you).
26+In that case, you can call ``get_script_prefix()``,
27+which will return the script prefix portion of the URL
28+for your Django project.
29+If your Django project is at the root of its webserver,
30+this is always ``"/"``, but it can be changed, for instance
31+by using the ``django.root`` (see
32+:ref:`How to use Django with Apache and mod_python <howto-deployment-modpython>`).
33+