标签:views tar pyc create cut world ges file mamicode
启动pycharm,然后新建一个名为quickstart的项目
安装Django(终端)
pip install django
或者下面的方法安装(mac的路径Pycharm-Preferences)
pycharm项目主目录下找到终端,新建项目
django-admin startproject QuickStart
python manage.py startapp polls
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse("Hello, world. You‘re at the polls index")
polls/urls.py
from django.urls import path from . import views urlpatterns = [ path(‘‘, views.index, name=‘index‘), ] # 正则表达式的路径 # 导入views函数 # views函数名字(后面会用到)
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘polls.apps.PollsConfig‘, ]
python manage.py rumserver
浏览器打开 127.0.0.1:8000/polls,如下图
标签:views tar pyc create cut world ges file mamicode
原文地址:https://www.cnblogs.com/soymilk2019/p/14805651.html