zoukankan      html  css  js  c++  java
  • 回顾创建项目报错

    一、创建虚拟环境

    1. 安装虚拟环境pip install virtualenv
    2. 创建虚拟环境virtualenv venv(venv就是虚拟环境名称,自定义)
    3. 进入虚拟环境venvScriptsactivate
    4. 安装所需软件:pip install django==1.9.6
    5. 退出deactivate

    二、创建项目

    1. 进入虚拟环境,执行命令python django-admin.py startproject znytest,(创建项目),若出现报错找不到django-admin.py,在venv找到复制到当前目录即可
    2. 创建应用 在znytest中执行命令 python manage.py startapp app01 若出现报错django.utils.encoding.DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xd5 in position 9: invalid continuation byte. You passed in 'C:\Users\xd5xc5xc4xfexd1xf4\znytest\db.sqlite3' (<type 'str'>)在settings中将数据库改为mysql即可
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.mysql',
              'NAME': 'test',    
              'USER': 'root',   
              'PASSWORD': 'root',    
              'HOST': '127.0.0.1',
              'PORT': '3306',
          }
      }
      

        在settings.py同目录下的__init__.py中

      import pymysql
      pymysql.install_as_MySQLdb()
      

        windows安装mysql:http://www.cnblogs.com/zhangningyang/p/7479112.html#lod6,若出现找不到msvcr120.dll安装vcredist_x64.exe即可,https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=40784

  • 相关阅读:
    第十周阅读内容
    第十周学习小结
    第九周阅读内容
    第九周学习小结
    第八周学习小结
    ..总结
    .总结
    总结.
    周总结
    总结
  • 原文地址:https://www.cnblogs.com/zhangningyang/p/10025905.html
Copyright © 2011-2022 走看看