install django采坑
Posted xiangjiaoai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了install django采坑相关的知识,希望对你有一定的参考价值。
1. install python 3
2. install pip
3. install virtual enviroment : python -m venv myvenv
4. 切换到virtualEnv :
[[email protected] djangogirls]# source myvenv/bin/activate
5. intall django
(myvenv) ~$ pip install django==1.8.2
6. 新建一个项目 (myvenv) [[email protected] djangogirls]# django-admin.py startproject mysite,检查一下 mysite 文件夹, 然后 配置 settings,
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.sqlite3‘, ‘NAME‘: os.path.join(BASE_DIR, ‘db.sqlite3‘), } }
7. 切换到mysite 目录,执行
(myvenv) [[email protected] mysite]# python manage.py runserver
错误1 :
No module named _sqlite3
解决方法: yum -y install sqlite-devel, 然后 切换到python 安装目录, cd Python-3.6.5, 执行 ./configure, ,make ,make install. 重新编译并且安装,问题解决
(myvenv) [[email protected] 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.
[[email protected] 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) [[email protected] 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
以上是关于install django采坑的主要内容,如果未能解决你的问题,请参考以下文章
环境初始化 Build and Install the Apache Thrift IDL Compiler Install the Platform Development Tools(代码片段