django-cms / djangocms-admin-style

django CMS Admin Style is a Django Theme tailored to the needs of django CMS.

Home Page:http://www.django-cms.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fieldsets / Inlines get lost in forms

jsoa opened this issue · comments

It become hard to navigate the form visually when using fieldsets and/or inlines

normal admin
admin-02

admin-style
admin-01

would be nice to see something like this
admin-04

Just something to make it easier to distinguish fieldsets / inlines.

Hello @jsoa thank you for the report. Would you be able to provide us with the Django models code to replicate?

here is a general model/admin layout I used, the main things are..

  • a fieldset,
  • a collapsed fieldset
  • an inline

models

from django.db import models

from cms.models.fields import PlaceholderField
from filer.fields.image import FilerImageField, FilerFileField
from taggit.managers import TaggableManager


LANGUAGE_CHOICES = (
    ('en', 'English'),
)


class Video(models.Model):
    title = models.CharField('title', max_length=255)
    slug = models.SlugField('slug')

    file = FilerFileField(
        null=True, blank=True, on_delete=models.PROTECT,
        related_name='%(app_label)s_%(class)s_file')
    external_url = models.URLField(
        'external url', max_length=500, blank=True, default='')
    description = models.TextField(blank=True, default='')

    image = FilerImageField(
        null=True, blank=True, on_delete=models.SET_NULL,
        related_name='%(app_label)s_%(class)s_image')

    credit = models.CharField(
        max_length=100, blank=True, default='',
        help_text='Generic attribution, i.e. Photo courtesy of John Doe.')

    keywords = TaggableManager(blank=True)
    body = PlaceholderField('video_body', related_name='video_body')

    def __unicode__(self):
        return self.title


class VideoCaption(models.Model):
    video = models.ForeignKey(Video)
    file = FilerFileField(null=True, blank=True, on_delete=models.PROTECT)
    url = models.URLField(blank=True, default='')
    language = models.CharField(
        max_length=5, choices=LANGUAGE_CHOICES, default='en')

    def __unicode__(self):
        return '{} - {}'.format(self.video.title, self.language)

admin.py

from django.contrib import admin

from cms.admin.placeholderadmin import PlaceholderAdminMixin

from .models import Video, VideoCaption


class VideoCaptionInline(admin.TabularInline):
    model = VideoCaption
    extra = 1


class VideoAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': ('title', 'slug', 'description', 'keywords')
            }),
        ('File', {
            'fields': ('file', 'external_url', )
            }),
        ('Meta', {
            'fields': ('credit', 'image', ),
            'classes': ['collapse']
            }),
        )
    inlines = [VideoCaptionInline]


admin.site.register(Video, VideoAdmin)

thank you @jsoa we'll have a look as soon as we can

Just heads up as I'm working on resolution for this (at least with stacked inlines) in #391