install django采坑

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



转载于:https://www.cnblogs.com/xiangjiaoai/p/9013253.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值