Django Error u“'polls” is not a registered namespace

后端 未结 13 2617
误落风尘
误落风尘 2021-01-31 07:41

Yesterday I was working on my first app using this tutorial. It\'s a Poll and Choice app. The first page displays the question and when you click on the question it\'s suppose t

13条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 08:25

    Django 2.0

    in yourapp/urls.py

    from django.urls import path
    from . import views
    
    app_name = 'yourapp'
    
    urlpatterns = [
        path('homepage/', views.HomepageView.as_view(), name='homepage'),
    ]
    

    in urls.py

    from django.contrib import admin
    from django.urls import path, include
    
    
    urlpatterns = [
        path('admin/', admin.site.urls),
        path('yourapp/', include('yourapp.urls')),
        ]
    

提交回复
热议问题