hello django

一、Python环境安装

1.安装Python pycharm django(略)

2.创建django项目scrapyweb

create project scrapyweb

cd scrapyweb

python manage.py startapp webapp

3.pycharm terminal中启动项目

python manage.py runserver

           访问网页: http://127.0.0.1:8000/

 

二、hello django

1.设置setting :INSTALLED_APPS中添加webapp 

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

LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

2.修改scrapyweb/urls.py

from django.conf.urls import url
from webapp.views import index
urlpatterns = [
    url(r'^$', index),
]

3.修改scrapyweb/webapp/views.py

from django.http import HttpResponse
def index(req):
    return HttpResponse('hello django')
  

hello django_第1张图片

你可能感兴趣的:(python/django)