How to prevent label wrap in Django Administration

48 views
Skip to first unread message

Bernd Wechner

unread,
Apr 19, 2015, 8:55:16 AM4/19/15
to django...@googlegroups.com

I'm just playing around with Django and have cut a simple model and all is working fine. The Django administration tool works a charm, and I can move onto some views and forms. But what puzzles me immensely is why editing a tuple looks like this (with crazy label wrap). Can I fix this any way? It's not an impressive use of screen real estate:



Thomas Lockhart

unread,
Apr 19, 2015, 10:08:52 AM4/19/15
to django...@googlegroups.com
> this any way? It's not an impressive use of screen real estate:...
>
Maybe my answer will provoke a better one, which would be a good thing,
but...

For non-admin pages you can tailor the labeling to whatever you want
your users to see; for admin you might want to show that more compactly
and efficiently.

How about making model labels which are shorter? Typically I use
something with a dozen characters or (much) less, and then put hints
about how to use it or other details into the help field. So "Trueskill
Initial Standard Deviation (phi0)" might be as simple (and
uninteresting) as "stddev" and the help might be "Enter an initial
standard deviation".

hth

- Tom

Larry Martell

unread,
Apr 19, 2015, 10:19:54 AM4/19/15
to django...@googlegroups.com
On Sun, Apr 19, 2015 at 7:21 AM, Bernd Wechner <bernd....@gmail.com> wrote:

I'm just playing around with Django and have cut a simple model and all is working fine. The Django administration tool works a charm, and I can move onto some views and forms. But what puzzles me immensely is why editing a tuple looks like this (with crazy label wrap). Can I fix this any way? It's not an impressive use of screen real estate:




You can override the CSS by setting it in the Media class for your form, e.g.:

class MyGameAdminForm(forms.ModelForm):
    class Media:
        css = {custom css here}

class GameAdmin(admin.ModelAdmin):
    form = MyGameAdminForm

It looks like the width for that display is set in forms.css:

.aligned label {
    display: block;
    padding: 3px 10px 0 0;
    float: left;
    width: 8em;
    word-wrap: break-word;
}

If you override the width that should do what you want. 

 
Reply all
Reply to author
Forward
0 new messages