A
A
Anton Toropov2018-07-03 08:52:41
Django
Anton Toropov, 2018-07-03 08:52:41

What for in Path to register a name of a route?

Good afternoon!
Django question.
What for in Path to register a name of a route: name='home'?
For example: without everything works the same way, or in what cases it is necessary to prescribe, and in which not? path(' ', views.index, name='home')
name='home'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2018-07-03
@tuychiev1988

In order to prescribe url by name in templates and code, and not explicitly:
return reverse('dashboard-index')instead of return '/dashboard/index/'.
The advantage is that named code is much easier to maintain and change.

A
Andrey Burov, 2018-07-03
@BuriK666

https://docs.djangoproject.com/en/2.0/topics/http/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question