django
sinat_14977477
内容简单记,不解请私
展开
-
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 · 4619 阅读 · 0 评论 -
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 · 324 阅读 · 0 评论 -
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 · 378 阅读 · 0 评论 -
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 · 6106 阅读 · 0 评论 -
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 · 4736 阅读 · 0 评论 -
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 · 1055 阅读 · 0 评论 -
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 · 290 阅读 · 0 评论 -
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 · 465 阅读 · 0 评论 -
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 · 3455 阅读 · 0 评论 -
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 · 443 阅读 · 0 评论 -
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 · 141 阅读 · 0 评论 -
django static和media文件在setting中的配置
templates文件的配置TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'templates', ], 'APP_DIRS': True, 'OPT...原创 2018-08-02 23:53:05 · 426 阅读 · 1 评论