Fork me on GitHub

Django web project

在virtualenv下

(myvenv) ~/djangogirls$ django-admin startproject mysite .

生成web 工程目录

djangogirls
├───manage.py
└───mysite
        settings.py
        urls.py
        wsgi.py
        __init__.py

设置settings

TIME_ZONE = 'Asia/Shanghai'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ALLOWED_HOSTS = ['127.0.0.1', '<your_username>.pythonanywhere.com']

使用默认数据库

python manage.py migrate

开启网络服务

(myvenv) ~/djangogirls$ python manage.py runserver

 在网页上输入网址

http://127.0.0.1:8000/

可以看到

It worked!
Congratulations on your first Django-powered page.

Next, start your first app by running python manage.py startapp [app_label].
You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

 

posted on 2017-06-15 13:36  pengyingh  阅读(235)  评论(0编辑  收藏  举报

导航