![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
django
Kevin2312
这个作者很懒,什么都没留下…
展开
-
django自定义过滤器
django自定义过滤器(其实就是一个函数)的步骤:在应用下建一个python package,名字一定是也只能是templatetags。在templatetags包下新建一个文件,文件名可由自己定义。比如我们在此定义一个判断是否为偶数的过滤器,过滤器函数最少一个参数,最多两个参数, 使用如下:filters.pyfrom django.template import Library...原创 2019-01-19 11:12:08 · 317 阅读 · 0 评论 -
django产生验证码图片
view文件相关代码:from django.shortcuts import HttpResponsefrom django.utils.six import BytesIOfrom PIL import Image, ImageDraw, ImageFontdef verify_code(request): # 引入随机函数模块 import random #...转载 2019-01-19 21:11:48 · 286 阅读 · 0 评论 -
no migrations to apply
当我们修改了模型,然后使用python manage.py makemigrations, python manage.py migrate 出现如下图所示:查看数据库中的django_migrations,如果对应的app中name的值存在0001_initial(app中的migrations文件夹对应着0001_initial.py),则说明已经被迁移了,所以不会再迁移。此时我们有两个...原创 2019-01-20 22:57:07 · 431 阅读 · 0 评论 -
window7 + django2.0 + xadmin2 + python3.6
1、假设你已经在window系统安装了python3.6,并创建了虚拟环境,安装了mysql,django2.0。2、在https://github.com/sshwsfc/xadmin/tree/django2 下载xadmin-django2.zip包,放在项目虚拟环境的Scripts文件夹下,并使用pip install xadmin-django2.zip安装xadmin。3、解压xa...原创 2019-01-21 14:50:02 · 212 阅读 · 0 评论 -
添加代码高亮设置
首先在https://ckeditor.com/cke4/addon/codesnippet定制下载codesnippet这个包。将下载的codesnippet文件夹解压放置于ckeditor(关于ckeditor相关内容,请参考添加富文本编辑器ckeditor)的plugins目录下(如果存在则替换)。配置ckeditor中的config.js。CKEDITOR.editorConfi...原创 2019-02-21 17:38:06 · 685 阅读 · 0 评论 -
django添加富文本编辑器
安装 pip install django-ckeditor。在settings.py中注册应用并添加相应配置INSTALLED_APPS = [ ... 'ckeditor',]CKEDITOR_CONFIGS = { 'comment_ckeditor': { 'toolbar': 'custom', 'toolbar_cu...原创 2019-02-21 17:46:26 · 597 阅读 · 0 评论 -
Django2.0上传图片到media文件夹以及在页面显示上传的图片
我们上传的图片一般保存在media文件夹中,那么使用django2.0怎么上传和显示呢。上传:dj2pro/settings.py...MEDIA_URL = '/media/'MEDIA_ROOT = os.path.join(BASE_DIR, 'media')booktest/models.pyfrom django.db import modelsclass PicT...原创 2019-02-20 14:11:16 · 2852 阅读 · 2 评论 -
Django2.0 + ListView + Pagination
折腾了一上午,终于把django中的ListView视图的分页效果做好了,话不多少,首先展示的是效果图:相关代码如下:views.jsclass IndexView(ListView): model = User template_name = 'users/index.html' paginate_by = 5 #每页显示多少条数据 ordering = ...原创 2019-05-10 12:48:48 · 389 阅读 · 0 评论