![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Django
459049715
2020.07.10 CHENGDU
展开
-
Django模型
说明:项目工程名testdb 添加模块blog第一步:安装PyMySQL驱动pip install PyMySQL说明:Python3不支持Python_mysql驱动。因此必须使用PyMySQL,在使用PyMySQL时必须在bolg的__init__.py中添加如下代码:import pymysqlpymysql.install_as_MySQLdb()第二步:在blog下...原创 2019-06-06 20:11:08 · 134 阅读 · 0 评论 -
搭建Django2.0+Python3+MySQL5时同步数据库时报错:
搭建Django2.0+Python3+MySQL5时同步数据库时报错:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None解决办法:找到Python安装路劲下的Python36-32\Lib\site-packages\djan...转载 2019-06-06 16:17:11 · 315 阅读 · 0 评论 -
Django表单
Get方式提交数据:第一步:在项目中添加search.py文件添加如下代码:from django.http import HttpResponsefrom django.shortcuts import render_to_response#表单def search_form(request): return render_to_response('search_fo...原创 2019-06-07 16:15:19 · 105 阅读 · 0 评论 -
Meta补充类的用法
情形一:将abstract设置为True后,模型类将不是一个普通的Django模型,而是作为一个抽象基类。范例:from django.db import modelsclass CommonInfo(models.Model): name = models.CharField(max_length=100) age = models.PositiveInteger...原创 2019-06-10 14:11:58 · 125 阅读 · 0 评论 -
Django项目中使用xadmin
第一步:从https://github.com/sshwsfc/xadmin下载源码包。解压复制xadmin文件夹到Django项目的自建包extra_apps。将extra_apps转变为source_root包。第二步:配置setting.py将extra_apps包加入到python的搜寻环境sys.path.insert(0, os.path.join(BASE_DIR, 'e...原创 2019-06-12 10:19:27 · 258 阅读 · 0 评论