Skip to content

martor's css overrides label "display" property and breaks django admin layouts #156

@immerrr

Description

@immerrr

Details

  • OS (Operating System) version: Ubuntu 20.04
  • Browser and browser version: Chromium 90.0
  • Django version: 3.2
  • Martor version & theme: 1.6.2, default theme

Steps to reproduce

  1. Configure and activate a virtualenv (here, with poetry)
$ cat pyproject.toml 
[tool.poetry]
name = "tmp"
version = "0.1.0"
description = ""
authors = ["immerrr <immerrr@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.8"
Django = "^3.2"
martor = "^1.6.2"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

$ poetry env use python
$ poetry install
$ poetry shell
  1. $ django-admin startproject martorbug .
  2. ./manage.py startapp core
  3. add 'core' and 'martor' to INSTALLED_APPS in martorbug/settings.py
  4. add two models
$ cat core/models.py 
from django.db import models
from martor.models import MartorField

# Create your models here.


class Foobar(models.Model):
    name = models.TextField()


class ModelWithFK(models.Model):
    name = models.TextField()
    description = MartorField()
    foobar = models.ForeignKey(Foobar, on_delete=models.CASCADE)

  1. register models with admin
$ cat core/admin.py 
from django.contrib import admin


from .models import Foobar, ModelWithFK

# Register your models here.


@admin.register(Foobar)
class FoobarAdmin(admin.ModelAdmin):
    fields = ['name']


@admin.register(ModelWithFK)
class ModelWithFKAdmin(admin.ModelAdmin):
    fields = ['name', 'foobar', 'description']
  1. ./manage.py createsuperuser --username user --email user@example.org (with some password)
  2. add 'STATIC_ROOT' to settings, run ./manage.py collectstatic
  3. ./manage.py runserver
  4. create a foobar via admin
  5. try creating a "model with fk"
  6. observe how a FK dropdown shows the label on the right hand side:

image

  1. disable the display property for fieldset .form-row div>label selector (that comes from martor.min.css) and notice how the labels are displayed correctly now:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions