简体   繁体   中英

Can't runserver on Django

I just started playing with Django, and I encountered a problem. Here's what it said when I tried to runserver.

ImproperlyConfigured: The included URLconf '' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

Here's what I did.

On setting.py:

INSTALLED_APPS = [
    'Siblog.apps.SiblogConfig',
    'django.contrib.admin',
    'django.contrib.auth',**strong text**
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

Project urls.py:

from django.contrib import admin
from django.urls import path, include

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

Siblog urls.py:

from django.urls import path
from . import views

urlpatterns = [
    path('', views.home, name='Siblog-home'),
]

Siblog views.py:

from django.shortcuts import render

def home(request):
    return render(request, 'Siblog/home.html')

Also the template I've created inside of the Siblog file:

<!DOCTYPE html>
<html>
 <head>
     <title></title>
 </head>
 <body>
     <h1>Siblog Home!</h1>>
 </body>        
</html>   

Simon at quick glance you need to modify a few things.

settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Siblog', ]

As long as you properly have the app set in the installed apps section the way you setup the rest of the project seems fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM