Opened 3 years ago

Closed 2 years ago

#17050 closed New feature (fixed)

add id attribute to individual model divs in the admin index

Reported by: scytale Owned by: thiderman
Component: contrib.admin Version: master
Severity: Normal Keywords: admin
Cc: vanessagomes Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: yes

Description

A client has requested color coding in the admin index page to help staff identify sections relevant to particular departments. In order to facilitate this I would like to give id attributes to the individual divs that enclose each "module" (app) section in the index page.

Attachments (2)

index_div_id.diff (737 bytes) - added by scytale 3 years ago.
fix_index_div_id.diff (4.3 KB) - added by H0ff1 3 years ago.

Download all attachments as: .zip

Change History (16)

Changed 3 years ago by scytale

comment:1 Changed 3 years ago by scytale

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from add id blah to individual msodel divs in the admin index to add id attribute to individual model divs in the admin index

comment:2 Changed 3 years ago by julien

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

That sounds reasonable. Using slugify on the app's title would probably be error prone, so instead I'd simply pass the app_label through to the template and use that instead. Also, you'd need to prefix the id, for example with "app-", to be sure it doesn't conflict with other styles (e.g. if you have an app called "changelist").

comment:3 Changed 3 years ago by H0ff1

  • Patch needs improvement unset

I fixed it and added a Unit-Test

comment:4 Changed 3 years ago by anonymous

  • Triage Stage changed from Accepted to Unreviewed

comment:5 Changed 3 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

Revert spam.

Changed 3 years ago by H0ff1

comment:6 Changed 3 years ago by H0ff1

Made some CodeStyle fixes on the patch

comment:7 Changed 3 years ago by vanessagomes

  • Cc vanessagomes added
  • Owner changed from nobody to vanessagomes

comment:8 Changed 3 years ago by vanessagomes

  • Owner vanessagomes deleted

comment:9 Changed 2 years ago by thiderman

  • Needs documentation set
  • Owner set to thiderman
  • Patch needs improvement set

I'll tackle this as part of my work on the Django sprint in Stockholm. I'll clean up the patch, make it apply to a current master and add some documentation to it!

comment:10 Changed 2 years ago by thiderman

  • Needs documentation unset
  • Patch needs improvement unset

Pull request added: https://github.com/django/django/pull/535

I'll be honest; I'm not completely sure about the documentation I added. I followed jezdez' advice about splitting the "Overriding templates" part into a more general part about customization. Feedback on that part is especially welcome.

comment:11 Changed 2 years ago by julien

  • Patch needs improvement set

Thanks a lot for the patch. It looks pretty good. I have some minor comments:

  • I don't think it's worth creating a separate test app for this (admin_individual_ids). Could you put those tests in admin_views instead? You might even be able to reuse existing models.
  • I'm not sure this is worth documenting at all. It's a really minor thing, and in the rare cases where developers might want to do this type of customization, they can easily inspect the DOM. So I recommend removing the doc from the patch.

comment:12 Changed 2 years ago by thiderman

I agree about the test app creation. I'll merge them into admin_views and check for some of the existing models instead.
Should I leave the release note in or should I remove that as well?

comment:13 Changed 2 years ago by thiderman

Pull request updated: https://github.com/django/django/pull/535

I removed everything from the documentation, including the release note. I merged the tests into the admin_views test and tested againt the first two generic models (Actor and Album). This made for a much cleaner patch!

comment:14 Changed 2 years ago by Julien Phalip <jphalip@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 2e2c4968f6b9b57354af7229687d179941ed74c5:

Fixed #17050 -- Added some CSS class names to the admin index pages to facilitate per-app or per-model style customizations. Thanks to scytale for the report and to H0ff1 and thiderman for their work on the patch.

Note: See TracTickets for help on using tickets.
Back to Top