Posted in Python onNovember 18, 2014
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, }
以上内容大部分精简至官方攻略,给需要的小伙伴们参考下吧
使用django-suit为django 1.7 admin后台添加模板
- Author -
hebedich声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@