使用django-suit为django 1.7 admin后台添加模板

yipeiwu_com6年前Python基础

django-grappelli里面使用inline似乎有点儿问题,换一个皮:

django-suit是2scoops推荐的第二个admin skin.
Supports: Django 1.4-1.7. Python: 2.6-3.
本文的环境是django 1.7.1

django-suit官网
安装指导链接
设置攻略

翻译搬运如下:

安装

复制代码 代码如下:

pip install django-suit

# settings.py
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
)

终端

复制代码 代码如下:

python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic

恭喜!基本安装已经完成!

官方攻略还有很多详细的设置,我发现这个插件不只是为了后台服务的,也附赠了许多form widget,在前台也可以善加利用:
举例如下:

datetime widget

复制代码 代码如下:

SuitDateWidget, SuitTimeWidget and SuitSplitDateTimeWidget extends original admin widgets by adding some additional output styling only. Widgets still uses same original JavaScript for calendar and time. You can see example in Demo app: User changeform:

from django.forms import ModelForm
from suit.widgets import SuitDateWidget, SuitTimeWidget, SuitSplitDateTimeWidget

class UserChangeForm(UserChangeForm):
    class Meta:
        model = User
        widgets = {
            'last_login': SuitSplitDateTimeWidget,
            'date_joined': SuitSplitDateTimeWidget,
        }

以上内容大部分精简至官方攻略,给需要的小伙伴们参考下吧

相关文章

Python2.7编程中SQLite3基本操作方法示例

本文实例讲述了Python2.7中SQLite3基本操作方法。分享给大家供大家参考,具体如下: 1、基本操作 # -*- coding: utf-8 -*- #!/usr/bin/e...

Python matplotlib的使用并自定义colormap的方法

0.前言 添加colormap的对象是灰度图,可以变成热量图,从而更加明显的发现一些规律,适用于一些雷达图像等 from PIL import Image # 将彩色图片转换成黑白图...

python 制作自定义包并安装到系统目录的方法

python 制作自定义包并安装到系统目录的方法

python 中的包的概念跟c++中的namespace很相似,在大型的工程开发中,多个开发人员很容使用相同的函数名,为了避免相同函数名带来的问题,就引入了包的概念。 在看别人写的程序中...

python http基本验证方法

如下所示: #!usr/bin/env python # -*- coding: utf-8 -*- import urllib2 LOGIN = "" PASSWORD = "...

Python中装饰器学习总结

本文研究的主要内容是Python中装饰器相关学习总结,具体如下。 装饰器(decorator)功能 引入日志 函数执行时间统计 执行函数前预备处理 执行函数后清理功能...