1. install python 3
2. install pip
3. install virtual enviroment : python -m venv myvenv
4. 切换到virtualEnv :
[root@zhuvm13662 djangogirls]# source myvenv/bin/activate
5. intall django
(myvenv) ~$ pip install django==1.8.2
6. 新建一个项目 (myvenv) [root@zhuvm13662 djangogirls]# django-admin.py startproject mysite,检查一下 mysite 文件夹, 然后 配置 settings,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
(myvenv) [root@zhuvm13662 mysite]# python manage.py runserver
错误1 :
解决方法: yum -y install sqlite-devel, 然后 切换到python 安装目录, cd Python-3.6.5, 执行 ./configure, ,make ,make install. 重新编译并且安装,问题解决
(myvenv) [root@zhuvm13662 mysite]# python manage.py runserver
Performing system checks…
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
May 09, 2018 - 03:28:38
Django version 1.8.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/ --因为有前面的警告,所以 火狐无法打开这个网址,执行警告里面的语句
Quit the server with CONTROL-C.
[root@zhuvm13662 mysite]# python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, contenttypes, auth
Synchronizing apps without migrations:
Creating tables…
Running deferred SQL…
Installing custom SQL…
Running migrations:
Rendering model states… DONE
Applying contenttypes.0001_initial… OK
Applying auth.0001_initial… OK
Applying admin.0001_initial… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying sessions.0001_initial… OK
(myvenv) [root@zhuvm13662 mysite]# python manage.py runserver
Performing system checks…
System check identified no issues (0 silenced).
May 09, 2018 - 03:30:03
Django version 1.8.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/ -- 可以正常访问,并且会有提示
Quit the server with CONTROL-C.
[09/May/2018 03:30:06]"GET / HTTP/1.1" 200 1767
[09/May/2018 03:30:06]"GET /favicon.ico HTTP/1.1" 404 1936
[09/May/2018 03:30:06]"GET /favicon.ico HTTP/1.1" 404 1936
手机扫一扫
移动阅读更方便
你可能感兴趣的文章