常用命令

  1. 生成应用

python manage.py start app(app_name)

2. 开启服务器

python manage.py runserver 0.0.0.0:8001

3. 声称以及修改数据模型

python manage.py makemigrations app(app_name)

4. 数据库模型移植

python manage.py migrate

5. 使用管理界面之前建立管理员用户(必须在cmd下运行)

python manage.py createsuperuser

ERROR

  1. ERROR:在使用python虚环境(安装了django)的情况下运行manage.py出错

    I:\code\python\web\django\django0510>I:\code\python\web\django\djangoenv\Scripts\python manage.py 8001
    Traceback (most recent call last):
    File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\core\management\__init__.py", line 324, in execute
    django.setup()
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models(all_models)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\apps\config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
    File "h:\64soft\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\contrib\auth\models.py", line 297, in <module>
    class AbstractUser(AbstractBaseUser, PermissionsMixin):
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\db\models\base.py", line 251, in __new__
    new_class.add_to_class(field.name, new_field)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\db\models\base.py", line 299, in add_to_class
    value.contribute_to_class(cls, name)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\db\models\fields\__init__.py", line 672, in contribute_to_class
    cls._meta.add_field(self)
    File "I:\code\python\web\django\djangoenv\lib\site-packages\django\db\models\options.py", line 312, in add_field
    self.local_fields.insert(bisect(self.local_fields, field), field)
    File "h:\64soft\python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
    ......
    File "h:\64soft\python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
    RuntimeError: maximum recursion depth exceeded while calling a Python object

    SOLUTION: 修改h:\64soft\python27\Lib\functools.py里的convert,如下

    convert = {
    '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
    ('__le__', lambda self, other: self < other or self == other),
    ('__ge__', lambda self, other: not self < other)],
    '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
    ('__lt__', lambda self, other: self <= other and not self == other),
    ('__gt__', lambda self, other: not self <= other)],
    '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
    ('__ge__', lambda self, other: self > other or self == other),
    ('__le__', lambda self, other: not self > other)],
    '__ge__ ': [('__le__', lambda self, other: (not self >= other) or self == other),
    ('__gt__', lambda self, other: self >= other and not self == other),
    ('__lt__', lambda self, other: not self >= other)]
    }
  2. ERROR: 访问url报错Forbidden (CSRF cookie not set.): xxx

    SOLUTION: 注释掉setting.py里的下列语句

python-Django框架的更多相关文章

  1. [Python] Django框架入门

    说明:Django框架入门 当前项目环境:python3.5.django-1.11 项目名:test1 应用名:booktest 命令可简写为:python manager.py xxx => ...

  2. 利用 Python django 框架 输入汉字,数字,字符,等。。转成二维码!

    利用 Python django 框架 输入汉字,数字,字符,等..转成二维码! 模块必备:Python环境 + pillow  + qrcode 模块 核心代码import qrcode qr = ...

  3. Python Django框架笔记(五):模型

    #前言部分来自Django Book (一)    前言 大多数web应用本质上: 1. 每个页面都是将数据库的数据以HTML格式进行展现. 2. 向用户提供修改数据库数据的方法.(例如:注册.发表评 ...

  4. Python Django框架笔记(三):django工作方式简单说明和创建用户界面

    (一)  说明 简单说明下django的工作方式,并举2个例子. (二)  Django工作方式 假定我们有下面这些文件 ,这里在前2篇的基础上增加了 templates目录(存放html文件) 和s ...

  5. Python Django框架笔记(一):安装及创建项目

     #推荐一本书<Python核心编程>(适合有一定基础的),美国人Wesley Chun编写的,京东.淘宝应该都有.我是觉得写的很好,详细.简洁.满满的干货,不像有的书整本看完也没什么用. ...

  6. python django框架(一)

    s4day63内容回顾: 1. 安装 2. 创建用户 + 授权 3. 连接 - 数据库 终端创建数据库(字符编码) - 数据表 终端 ORM pymysql create ...)engine=inn ...

  7. [Python] Django框架入门5——静态文件、中间件、上传图片和分页

    说明: 本文主要描述Django其他的内容,涉及静态文件处理.中间件.上传文件.分页等. 开发环境:win10.Python3.5.Django1.10. 一.静态文件处理 在Django项目的静态文 ...

  8. python Django框架正式准备工作

    之前由于不太了解数据库方面的知识,但经过一段时间的web应用的开发学习,成功的用其他框架连接了数据库,并完成了相关操作,数据爬取也初识了,更了解了python这门语言的语法,但路还很长,因此现在才能正 ...

  9. python django框架+vue.js前后端分离

    本文用于学习django+vue.js实现web前后端分离协作开发.以一个添加和删除数据库书籍应用为实例. django框架官方地址:https://www.djangoproject.com/ vu ...

  10. Python Django框架笔记(六):模板

    (一){%%}和{{ }} {% for post in posts %} <a href=""><h2>{{ post.title }}</h2&g ...

随机推荐

  1. sklearn-GDBT

    GDBT 可以解决分类和回归问题 回归问题 def __init__(self, loss='ls', learning_rate=0.1, n_estimators=100, subsample=1 ...

  2. 宿主机-免密登录Docker容器

    CentOS7 安装Docker 讨论QQ:1586558083 目录 一.检查系统内核 二.安装Docker 2.1 安装 2.2 查看docker版本 2.3 启动docker 三.建立docke ...

  3. 部署k8s集群之环境搭建和etcd单节点安装

    环境搭建以及etcd 单节点安装过程 安装之前的环境搭建 在进行k8s安装之前先把虚拟机准备好,这里准备的是三台虚拟机 主机名 ip地址 角色 master 172.16.163.131 master ...

  4. dubbo学习笔记二(服务调用)

    项目结构 代码示例 由于之前的IEchoService 的一个方法只是在服务端控制台打印,不便在浏览器测试,所以新添加的方法 api和服务端代码变更 public interface IEchoSer ...

  5. 记一次nodemanager无法启动的情况

    早上看CDH发现有一个nodemanager挂掉 然后查看对应的日志. 发现在日志里面并没有错误.,然然后发现服务器的磁盘满了,赶紧清理磁盘空间 清理磁盘的时候发现主要是/tmp目录下面生成了很多  ...

  6. python多线程之_thread

    多线程类似于同时执行多个不同程序,多线程运行有如下优点: 使用线程可以把占据长时间的程序中的任务放到后台去处理. 用户界面可以更加吸引人,这样比如用户点击了一个按钮去触发某些事件的处理,可以弹出一个进 ...

  7. 数据库 (二):MySQL密码策略与用户管理

    为了加强安全性,MySQL5.7为root用户随机生成了一个密码可通过# grep "password" /var/log/mysqld.log 命令获取MySQL的临时密码用该密 ...

  8. Mac安装PHP(Homebrew/php弃用、其他第三方tap也已经弃用或者迁移后的安装配置方案)

    一.前言 看网上很多资料,大多数都是 mac安装php,只需要: brew tap homebrew/php brew install phpXX 安装php扩展只需要: brew install p ...

  9. [CF#592 E] [二分答案] Minimizing Difference

    链接:http://codeforces.com/contest/1244/problem/E 题意: 给定包含$n$个数的数组,你可以执行最多k次操作,使得数组的一个数加1或者减1. 问合理的操作, ...

  10. lightinthebox程序bug zencart

    1.清空旧产品分类,新增分类与产品,前台首页不显示中间栏,提示无产品:布局设置 -(Main Page - Opens with Category)首页显示某分类,把新增的某分类ID填上或者设为0即可 ...