1,创建项目demo:
python
django-admin startproject demo
2,创建应用程序
python
python manage.py startapp myapp
3,在项目的setting.py中注册应用程序
python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp'
]
4,在项目的urls.py文件中注册路由
备注:在应用程序myapp中创建urls.py文件,用于访问myapp的路由使用
python
urlpatterns = [
path('admin/', admin.site.urls),
path('myapp/', include('myapp.urls')),
]