Previously, we introduced Django-grappelli to add a template to the admin. However, inline is found to be a problem during use, so we changed the Django-suit we want to talk about today, it seems a little better to use inline in django-grappelli. it seems a bit problematic to change the skin:
Django-suit is the second admin skin recommended by 2scoops.
Supports: Django 1.4-1.7. Python: 2.6-3.
The environment in this article is django 1.7.1
Django-suit official website
Installation Guide
Strategy
The translation is as follows:
Install
The code is as follows:
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 ',
)
Terminal
The code is as follows:
Python manage. py makemigrations
Python manage. py migrate
Python manage. py collectstatic
Congratulations! The basic installation is complete!
There are still many detailed settings in the official strategy. I found that this plug-in is not only for background services, but also comes with many form widgets that can be used in the previous stage:
Example:
Datetime widget
The code is as follows:
SuitDateWidget, SuitTimeWidget and 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,
}
Most of the above content is simplified to the official strategy. For more information, see.