- 博客(13)
- 收藏
- 关注
原创 django富文本django-ckeditor
参考地址: https://www.cnblogs.com/ianduin/p/7732983.html https://github.com/django-ckeditor/django-ckeditor安装安装django-ckeditor 安装pillow,图像上传使用pip install django-ckeditorpip install pillow配置d...
2018-08-06 22:56:49
424
原创 django 搜索功能的实现
参考文章: 简单搜索功能实现:https://www.zmrenwu.com/post/19/ 复杂搜索功能实现,使用django-haystach:https://github.com/django-haystack/django-haystackviews.py: # 搜索功能实现 q = request.GET.get('q', '') error_...
2018-08-05 23:15:43
6163
原创 django列表筛选功能的实现
views,中设置请求的类型class LawDetailView(View): def get(self, request, law_id): type = request.GET.get('type', '') law = Law.objects.get(id=law_id) return render(request, 'zcf...
2018-08-05 21:48:42
4808
原创 django 分页实现(django-pure-pagination)
使用django-pure-pagination实现django的分页功能: https://github.com/jamespacileo/django-pure-pagination安装pip install django-pure-pagination添加到setting中:INSTALLED_APPS = ( ... 'pure_paginatio...
2018-08-05 20:28:05
1092
原创 xadmin全局配置(主题配置、后台名称页脚版权、菜单样式、app中文名称)
配置后台主题import xadminfrom xadmin import viewsfrom .models import Law# 配置后台主题class BaseSetting(object): enable_themes = True use_bootswatch = Truexadmin.site.register(views.BaseAdminVi...
2018-08-04 23:46:07
3528
原创 xadmin的使用
xadmin的安装参考相关网站: http://sshwsfc.github.io/xadmin/ https://github.com/sshwsfc/xadmin安装xadminpip install xadmin 如果是django2.0版本,安装django2.0版本,在github分支中下载zip文件进行安装 pip install xadmin-django2....
2018-08-04 16:39:45
491
原创 Django admin的简单使用
创建models makemigrations migrate createsuperuser 在当前app下的admin.py文件中编写代码,如下:from django.contrib import adminfrom .models import Lawclass LawAdmin(admin.ModelAdmin): passadmin.site.re...
2018-08-03 22:58:28
172
原创 django 设置中文和使用北京时间
Django的setting中代码如下:# Internationalization# https://docs.djangoproject.com/en/2.0/topics/i18n/LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True更改后:...
2018-08-03 22:48:08
4699
原创 django static和media文件在setting中的配置
templates文件的配置TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'templates', ], 'APP_DIRS': True, 'OPT...
2018-08-02 23:53:05
481
1
原创 django models的简单配置
代码如下:from datetime import datetimefrom django.db import models# 政策法规模型class Law(models.Model): type = models.CharField(choices=(('fl', '法律'), ('xzfg', '行政法规'), ('bmgz', '部门规章'), ...
2018-08-02 23:44:34
349
原创 django views与url的简单配置
如下代码所示:from django.shortcuts import renderfrom django.views import Viewclass LawlistView(View): def get(self, request): return render(request, 'zcfg-list.html', {})class LawDetail...
2018-08-02 23:43:06
781
原创 nginx+gunicorn配置django环境
安装gityum install gitgit的简单使用介绍1 初始化 git init 2 生成ssh Key ssh-keygen -t rsa -C “你的邮箱@qq.com” 3 将~/.ssh/id_rsa.pub写入到gitee设置SSH中 4 确认ssh连接 ssh -T git@gitee.com 返回Welcome 5 到安装网站根目录 git ...
2018-07-31 23:07:49
356
原创 Centos 7.4 安装Django环境
安装python3.6.5centos默认安装python2.7,更换为python3,为简便操作,使用Anaconda https://www.anaconda.com/ 1 下载anaconda 2 安装anaconda 3 更新bashrc source ~/.bashrc note:提示unbip2,使用yum install bzip2安装mysql参考:http...
2018-07-27 21:45:28
514
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人