使用django-suit为django 1.7 admin后台添加模板
django-grappelli里面使用inline似乎有点儿问题,换一个皮:
django-suit是2scoops推荐的第二个admin skin.
supports: django 1.4-1.7. python: 2.6-3.
本文的环境是django 1.7.1
翻译搬运如下:
安装
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,
}
以上内容大部分精简至官方攻略,给需要的小伙伴们参考下吧
下一篇: cad对象特性不显示怎么解决?