Django, a high-level Python web application framework, uses a technique called URLconf (URL configuration) to determine how URLs are mapped to views. This technique involves the use of Python code to define what is essentially a table of contents for your web app.
Creating a URL involves primarily two components: ‘urls.py’ file and django custom template tag ‘url’.
In `urls.py` you will define a list of URL patterns for Django to match with incoming HTTP request URLs which are then routed to the respective view. Here’s an illustrative example:
```
from django.urls import path
from . import views
urlpatterns = [
path(‘articles/’, views.article_list, name=‘article-list’),
]
```
In this example, `articles/` is the URL pattern to match. `views.article_list` is the Python function Django will run when this URL pattern is matched. The `name` argument assigns a name to this URL pattern, which would be used in the templates.
The ‘custom template tag’ `url` is the other half of URL generation, It is used in HTML templates that Django uses to generate views. This Django custom template tag enables you to dynamically generate URLs in your HTML templates, using the `name` you assigned in your `urls.py` file.
```
Click here to view the list of articles.
```
By clicking this link, Django will execute the `article_list` view function. In case the URL changes in `urls.py`, you don’t need to manually change each URL in your templates, because you are using the URL´s name and Django does the referencing for you.
Using these two components, you can dynamically generate URLs in your Django applications. To generate more complex URL patterns, Django allows using route parameters and regular expressions in its URLconf feature.
You can find more information about Django’s URLconf at its official documentation:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
It is also recommended to refer to the official Django tutorial, which includes a section on URL creation: https://docs.djangoproject.com/en/3.2/intro/tutorial01/
Please note all the above illustrations assume you have the basic setup of Django Applications.
Sources:
1. Django Project, URL Dispatcher (URL Configuration) – (https://docs.djangoproject.com/en/3.2/topics/http/urls/)
2. Django Project, Getting Started (https://docs.djangoproject.com/en/3.2/intro/tutorial01/)
3. Django Project, Named URL (https://docs.djangoproject.com/en/3.2/topics/http/urls/#naming-url-patterns)