V
V
Vlad2422019-01-25 21:44:06
Django
Vlad242, 2019-01-25 21:44:06

I have a version of django 2.1 and how do I know that in urls.py I need to write path instead of url?

I have django 2.1 and how do I know that in urls.py you need to write path instead of url, but the terminal cursed me for an error and then I changed it to urls and everything works. But why is that? But how do I know urls should be written in django 1 versions, but I have django 2 ? Here is my code (it works even though I have django 2 version)

from django.contrib import admin
from django.conf.urls import include, url


urlpatterns = [

    url('admin/', admin.site.urls),
    url('music/', include('music.urls')),
]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
marazmiki, 2019-01-26
@Vlad242

Starting with version 2.0, all the url handling stuff is stored in django.urls, not django.conf.urlslike before. The old url()one is available in this package, probably for compatibility.
More details in the release description (see the last paragraph)

K
Konstantin Malyarov, 2019-01-25
@Konstantin18ko

Go to the main folder where settings.py is located, there is urls.py where the examples are written.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question