码迷,mamicode.com
首页 > 其他好文 > 详细

install django采坑

时间:2018-05-09 14:58:27      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:make   class   module   --   python   pes   pts   bsp   无法   

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‘),
    }
}
7. 切换到mysite 目录,执行

(myvenv) [root@zhuvm13662 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) [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



install django采坑

标签:make   class   module   --   python   pes   pts   bsp   无法   

原文地址:https://www.cnblogs.com/xiangjiaoai/p/9013253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!