Use django suit to add templates to the django 1.7 admin background

  • 2020-04-02 14:21:43
  • OfStack

Using inline in django-grappelli seems to be a bit of a problem.

Django-suit is the second admin skin recommended by 2scoops.
Supports: Django 1.4-1.7. Python: 2.6-3.
The environment for this article is django 1.7.1

(link: http://djangosuit.com/)
(link: http://django-suit.readthedocs.org/en/develop/)
(link: http://django-suit.readthedocs.org/en/develop/configuration.html#full-example)

The translation is carried as follows:

The installation


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


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

A: congratulations! The basic installation is complete!

The official guide also has a number of detailed Settings, and I found that the plugin is not just for background services, but also comes with a number of form widgets that can be used in the foreground as well:
Examples are as follows:

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

Most of the above content is simplified to the official guide, for those who need it


Related articles: