python-Django框架
常用命令
- 生成应用
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
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)]
}
ERROR: 访问url报错Forbidden (CSRF cookie not set.): xxx
SOLUTION: 注释掉setting.py里的下列语句

python-Django框架的更多相关文章
- [Python] Django框架入门
说明:Django框架入门 当前项目环境:python3.5.django-1.11 项目名:test1 应用名:booktest 命令可简写为:python manager.py xxx => ...
- 利用 Python django 框架 输入汉字,数字,字符,等。。转成二维码!
利用 Python django 框架 输入汉字,数字,字符,等..转成二维码! 模块必备:Python环境 + pillow + qrcode 模块 核心代码import qrcode qr = ...
- Python Django框架笔记(五):模型
#前言部分来自Django Book (一) 前言 大多数web应用本质上: 1. 每个页面都是将数据库的数据以HTML格式进行展现. 2. 向用户提供修改数据库数据的方法.(例如:注册.发表评 ...
- Python Django框架笔记(三):django工作方式简单说明和创建用户界面
(一) 说明 简单说明下django的工作方式,并举2个例子. (二) Django工作方式 假定我们有下面这些文件 ,这里在前2篇的基础上增加了 templates目录(存放html文件) 和s ...
- Python Django框架笔记(一):安装及创建项目
#推荐一本书<Python核心编程>(适合有一定基础的),美国人Wesley Chun编写的,京东.淘宝应该都有.我是觉得写的很好,详细.简洁.满满的干货,不像有的书整本看完也没什么用. ...
- python django框架(一)
s4day63内容回顾: 1. 安装 2. 创建用户 + 授权 3. 连接 - 数据库 终端创建数据库(字符编码) - 数据表 终端 ORM pymysql create ...)engine=inn ...
- [Python] Django框架入门5——静态文件、中间件、上传图片和分页
说明: 本文主要描述Django其他的内容,涉及静态文件处理.中间件.上传文件.分页等. 开发环境:win10.Python3.5.Django1.10. 一.静态文件处理 在Django项目的静态文 ...
- python Django框架正式准备工作
之前由于不太了解数据库方面的知识,但经过一段时间的web应用的开发学习,成功的用其他框架连接了数据库,并完成了相关操作,数据爬取也初识了,更了解了python这门语言的语法,但路还很长,因此现在才能正 ...
- python django框架+vue.js前后端分离
本文用于学习django+vue.js实现web前后端分离协作开发.以一个添加和删除数据库书籍应用为实例. django框架官方地址:https://www.djangoproject.com/ vu ...
- Python Django框架笔记(六):模板
(一){%%}和{{ }} {% for post in posts %} <a href=""><h2>{{ post.title }}</h2&g ...
随机推荐
- Manacher模版
现在讲的也是一种处理字符串的方法,叫做Manacher,有点像“马拉车” 1179: [视频][Manacher]最长回文子串 时间限制: 1 Sec 内存限制: 128 MB提交: 209 解决 ...
- linux基础命令<二>
1.关机 init 0 poweroff halt shutdown –h now 2.重启 init 6 reboot shutdown –r now 3.查询都有那些用户在系统 ...
- Postman之简单使用
前提:已获得接口文档 / 抓包数据 1.启动Postman 直接在这个页面输入数据(不用管其他的地方!!!) 2.按照接口文档填入 注意蓝色框中的数据 请求方式:POST(几乎都是使用POST/GET ...
- [Next] next中文文档
Next.js 是一个轻量级的 React 服务端渲染应用框架. 怎么使用 安装 在项目文件夹中运行: npm install --save next react react-dom 将下面脚本添加到 ...
- pc端和移动端的“窗口”(viewport)故事(part1)
A tale of two viewports - part one 在以下的系列文章中,我将为大家解释浏览器中的视窗和一些重要的元素的尺寸是如何起作用的,如:大家最熟悉的html元素以及window ...
- pycharm设置用滑轮改变字体大小
在电脑第一次安装pycharm之后,发现每次调整代码界面的字体,总是需要到setting里面调整,这样非常不方便,特别是对于代码量很多的时候,我们有时候需要把目光聚焦到某一句代码,这个时候就需要放大, ...
- Hadoop大数据平台入门——HDFS和MapReduce
随着硬件水平的不断提高,需要处理数据的大小也越来越大.大家都知道,现在大数据有多火爆,都认为21世纪是大数据的世纪.当然我也想打上时代的便车.所以今天来学习一下大数据存储和处理. 随着数据的不断变大, ...
- [转载] Java注解
目录 元注解 @Retention @Documented @Target @Inherited @Repeatable 注解语法 ---------------------------------- ...
- PHP之常用操作
在最高权限下执行相关命令 1)查看PHP配置 php --ini Configuration File (php.ini) Path: /www/server/php//etc Loaded Conf ...
- Slimvoice快速而小巧
这可行吗?绝对没问题.完全加载的最大页面只有230 KB.因为所有内容都被缓存和压缩,所以随后查看的每个页面只有大约6 KB,这比我见过的具有相同功能的SPA要小得多. Slimvoice快速而小巧, ...