1

So we are using Django's sites contrib app, and a particular page in the admin is going to be pretty packed, so we're saving space any way we can. Our site profiles each have an abbreviation associated with it, which would tighten things up a lot, so we want to use those instead of the full names in the admin form. Not sure what the best way of doing this is.

I saw this post, and it looked like it might be along the lines of what I'm after, but I really don't want to have to create an entirely new form. Seems like overkill just to make a single field display differently. Any ideas on what the best way to do this is? Presently, I'm thinking about a javascript solution -- send over a map with the abbreviations keyed to the site ids and do some replacing, but that seems a little hacky.

Community
  • 1
  • 1
meesterguyperson
  • 1,726
  • 1
  • 20
  • 31

1 Answers1

0

The point of forms is to control how fields are displayed. It shouldn't be much effort to make a new form with the correct choice names.

A Javascript solution has a couple of points to be aware of:

  1. You need to build & maintain the list of names and abbreviations as JSON, and correctly encode it when you include it in the page

  2. You'll have to override the template for that admin page to be able to include the custom J S

  3. It won't work for people who have JS disabled

  4. The page will "jump" as the browser will first render the page with the values from the form, before you JS changes them and the browser re-renders the page.

Craig Blaszczyk
  • 973
  • 1
  • 7
  • 20