V
V
vikholodov2018-04-19 17:01:42
Django
vikholodov, 2018-04-19 17:01:42

How to limit url searches in django to avoid intersections?

Hello colleagues.
I caught a small problem:
The bottom line is that urls are on the same level as admin, i.e. site/product1/ , as a result, site/admin/ goes to my view and looks for something that is not needed there.
I suppose that you need to write your own converter? Please point in the right direction, if not difficult, then with an example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-04-19
@vikholodov

WSGIHandler iterates through urlpatterns one by one until it encounters a matching URL pattern. All others defined after it will not be taken into account. So you just need to set a fairly specific pattern.

A
Alexander Vorobyov, 2018-04-21
@alex_vv

Everything is simpler - swap them in urls.py:
1. site/admin/ # the first link to the amino
2. site/product1/ # only after the link to the view with parameters.
Then everything will be OK and you do not need to write anything.
PS Well, usually for products they create links like site/product/1 - then they will definitely not intersect with other views.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question