Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Links to Views | Templates
Django: First Dive
course content

Зміст курсу

Django: First Dive

Django: First Dive

1. Get Started
2. Write the First Page
3. Models
4. Working with Database
5. Templates
6. Request Handling

Links to Views

The DTL allows us to create links to Views directly. What is meant by this? The URL addresses to Views can be changed while the development process. DTL finds the using URL automatically through the URL pattern name.

Look at the implemented URL pattern inside the urls.py file:

The DTL has tools that insert links from the URL pattern through the pattern name into the HTML page. Such operations are performed using the following syntax:

For example, the link to the post list:

Note

The quotes inside the url function and the href parameter should be different.

Result

Now we have this link in the main page in the browser:

The HTML document structure in browser:

The link opens the http://127.0.0.1:8000/posts/ URL address in your browser.

Thus, you can create links to any endpoint of your application, and changing the URL address will not affect the pages, which protects you from additional changes in the HTML pages.

Все було зрозуміло?

Секція 5. Розділ 5
We're sorry to hear that something went wrong. What happened?
some-alt