| | 643 | |
| | 644 | get_script_prefix() |
| | 645 | ------------------- |
| | 646 | |
| | 647 | .. versionadded:: 1.0 |
| | 648 | |
| | 649 | Normally, you should always use |
| | 650 | :func:`~django.core.urlresolvers.reverse` or |
| | 651 | :func:`~django.db.models.permalink` to define URLs |
| | 652 | within your application. |
| | 653 | However, if your application constructs |
| | 654 | part of the URL hierarchy itself you may occasionally |
| | 655 | need to generate URLs. |
| | 656 | In that case, you need to be able to find the base URL |
| | 657 | of the Django project within its web server |
| | 658 | (normally, :func:`~django.core.urlresolvers.reverse` |
| | 659 | takes care of this for you). |
| | 660 | In that case, you can call ``get_script_prefix()``, |
| | 661 | which will return the script prefix portion of the URL |
| | 662 | for your Django project. |
| | 663 | If your Django project is at the root of its webserver, |
| | 664 | this is always ``"/"``, but it can be changed, for instance |
| | 665 | by using the ``django.root`` (see |
| | 666 | :ref:`How to use Django with Apache and mod_python <howto-deployment-modpython>`). |
| | 667 | |