1.打开pycharm File--->New Project
2.使用命令 django-admin startproject 项目名 新建Django项目
执行命令后
3.创建APP
使用命令 python manager.py startapp app名
4.测试方法
views.py
from django.shortcuts import render
# Create your views here.
from django.shortcuts import HttpResponse
def index(request):
return HttpResponse("hello, yjl")
urls.py
from django.contrib import admin
from django.urls import path
from yjl_demo import views
urlpatterns = [
path('admin/', admin.site.urls),
path('index/', views.index)
]
5.运行代码
命令 python manage.py runserver 0.0.0.0:8888