Reputation: 11
When I adding the library path in app general of urls, send me the next message: "E0611:No name 'path' in module 'django.urls'" and "E0611:No name 're_path' in module 'django.urls'".
It is the code in generals urls:
from django.contrib import admin
from django.urls import include,re_path
from django.urls import include,path
from homepage.views import homepage
urlpatterns = [
path(r'^admin/', admin.site.urls),
path(r'^',include('homepage.urls')),
]
urlpatterns +=[
re_path(r'home/',include('homepage.urls'))
]
The version I using is v2.1
Thanks for you help me.
Upvotes: 0
Views: 293
Reputation: 151
In official documentation they explain cool.you need to study documentation more
#Example of using re_path
from django.urls import include, re_path
urlpatterns = [
re_path(r'^index/$', views.index, name='index'),
re_path(r'^bio/(?P<username>\w+)/$', views.bio, name='bio'),
re_path(r'^weblog/', include('blog.urls')),
...
]
#Example of using path
from django.urls import include, path
urlpatterns = [
path('index/', views.index, name='main-view'),
path('bio/<username>/', views.bio, name='bio'),
path('articles/<slug:title>/', views.article, name='article-detail'),
path('articles/<slug:title>/<int:section>/', views.section, name='article-section'),
path('weblog/', include('blog.urls')),
...
]
documentation :
Upvotes: 1