Answer the question
In order to leave comments, you need to log in
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
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question