使用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,
        }

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

相关文章

Centos下实现安装Python3.6和Python2共存

写在前面 centos6.8中默认自带的python版本为python2.6,那么这里需要将其改为python3 下载并解压 官方下载地址为 https://www.python.o...

Python selenium实现微博自动登录的示例代码

Python selenium实现微博自动登录的示例代码

(一)编程环境 操作系统:Win 10 编程语言:Python 3.6 (二)安装selenium 这里使用selenium实现。 如果没有安装过python的seleni...

python 中文字符串的处理实现代码

>>> teststr = '我的eclipse不能正确的解码gbk码!' >>> teststr '\xe6\x88\x91\xe7\x9a\x84...

Scrapy框架CrawlSpiders的介绍以及使用详解

Scrapy框架CrawlSpiders的介绍以及使用详解

在Scrapy基础——Spider中,我简要地说了一下Spider类。Spider基本上能做很多事情了,但是如果你想爬取知乎或者是简书全站的话,你可能需要一个更强大的武器。CrawlSp...

解决Python selenium get页面很慢时的问题

解决Python selenium get页面很慢时的问题

driver.get("url")等到页面全部加载渲染完成后才会执行后续的脚本。 在执行脚本时,driver.get("url") ,如果当前的url页面内容较多加载特别慢,很费时间,但...