URL dispatcher

A clean, elegant URL scheme is an important detail in a high-quality Web application. Django lets you design URLs however you want, with no framework limitations. There’s no .php or .cgi required, and certainly none of that 0,2097,1-1-1928,00 nonsense. See Cool URIs don’t change, by World Wide Web creator Tim Berners-Lee, for excellent arguments on why URLs should be clean and usable. Overview To design URLs for an app, you create a Python module informally called a URLconf (URL configuration).

urls.get_script_prefix()

get_script_prefix() [source] Normally, you should always use reverse() 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, 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

urls.resolve()

resolve(path, urlconf=None) [source] path is the URL path you want to resolve. As with reverse(), you don’t need to worry about the urlconf parameter. The function returns a ResolverMatch object that allows you to access various metadata about the resolved URL. If the URL does not resolve, the function raises a Resolver404 exception (a subclass of Http404) .

urls.ResolverMatch

class ResolverMatch [source] func The view function that would be used to serve the URL args The arguments that would be passed to the view function, as parsed from the URL. kwargs The keyword arguments that would be passed to the view function, as parsed from the URL. url_name The name of the URL pattern that matches the URL. app_name The application namespace for the URL pattern that matches the URL. app_names New in Django 1.9. The list of individual nam

urls.ResolverMatch.app_name

app_name The application namespace for the URL pattern that matches the URL.

urls.ResolverMatch.app_names

app_names New in Django 1.9. The list of individual namespace components in the full application namespace for the URL pattern that matches the URL. For example, if the app_name is 'foo:bar', then app_names will be ['foo', 'bar'].

urls.ResolverMatch.args

args The arguments that would be passed to the view function, as parsed from the URL.

urls.ResolverMatch.func

func The view function that would be used to serve the URL

urls.ResolverMatch.kwargs

kwargs The keyword arguments that would be passed to the view function, as parsed from the URL.

urls.ResolverMatch.namespace

namespace The instance namespace for the URL pattern that matches the URL.