E
E
Egegey2021-06-01 02:31:07
Django
Egegey, 2021-06-01 02:31:07

Is it correct to specify addresses like this in the root urls.py?

Suppose the request goes to the address localhost:8000/main/
I understand correctly that in any case, Django will go to the first application, look for it main/, but not find it.
Then he will go to the second and find it there.
Is it correct to write like this? Is such a code practiced?

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('one.urls')),
    path('', include('two.urls')),
]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WStanley, 2021-06-01
@Egegey

Yes, you understand correctly. I think that this is not particularly correct, but I wrote this way and it has been working on one of the sites for more than a year, there are no problems.
I just left a comment, just in case

# Эти 2 роута всегда внизу! posts последний!
    path('', include('front.urls')),
    path('', include('posts.urls')),

This is due to the fact that the SEO specialist asks to make all links short on the site, i.e. they are all kinds
domain.ru/my_link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question