Django 1.10官方文档:https://docs.djangoproject.com/en/1.10/intro/tutorial01/
1.查看django版本
python -m django --version
2.创建项目
django-admin startproject mysite
3.调试工程
python manage.py runserver [8080/0.0.0.0:8000]
4.创建APP
python manage.py startapp polls
5.编辑APP视图(polls/views.py)
from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You‘re at the polls index.")
6.编辑APP链接(polls/urls.py)
from django.conf.urls import url from . import views urlpatterns = [ url(r‘^$‘, views.index, name=‘index‘), ]
7.编辑工程urls.py
# mysite/urls.py from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r‘^polls/‘, include(‘polls.urls‘)), url(r‘^admin/‘, admin.site.urls), ]
按照上面的流程就可以做出一个helloworld网页了
时间: 2024-10-19 08:52:21