G
G
Golopolos2021-08-22 17:15:38
Django
Golopolos, 2021-08-22 17:15:38

How to make a url?

There are two urls

path('<category_name>/<slug:article_slug>'),
path('user/<int:pk>', views.user_profile),

When going to a user's profile, django thinks it's an article and doesn't open it.
What is the right way to be in this situation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Nesterov, 2021-08-22
@Golopolos

Django checks urls in order and if the first one matches the condition (and in your case it does), then it does not consider further ones.

A
akrvch, 2021-08-22
@akrvch

Add articles (or other name) at the beginning

path('articles/<category_name>/<slug:article_slug>')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question