How to adjust grid in Django Admin Forms

699 views
Skip to first unread message

traveller3141

unread,
Mar 25, 2012, 7:42:08 PM3/25/12
to django...@googlegroups.com
I've just created a model in Django and want to use the admin form to
enter information for it. The problem I'm having is that my field
names are so long that they overlap the edit boxes where their values
are to be entered.

If one follows the tutorial in the Django website, it's as if the
label "Question:" overlapped the edit box where one was supposed to
enter a question.

Any thoughts, comments or suggestions would be greatly appreciated.

Thanks

Steven

unread,
Mar 26, 2012, 9:53:01 AM3/26/12
to Django users
I've just created a model in Django and want to use the admin form to
enter information for it. The problem I'm having is that my field
names are so long that they overlap the edit boxes where their values
are to be entered.

If one follows the tutorial in the Django website, it's as if the
label "Question:" overlapped the edit box where one was supposed to
enter a question.

The file "fieldset.html" in the /admin/includes sub-directory seems to
have the relevant code:

<fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }} - Foo Test</h2>{%
endif %}
{% for line in fieldset %}
<div class="form-row{% for field in line %}{% if
field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor
%}">
{% for field in line %}
<div>
{{ field.label_tag }}{{ field.field }}
</div>
{% endfor %}
</div>
{% endfor %}
</fieldset>

What I can't figure out is how to allocate more space to
{{ field.label_tag }}, so that it is not covered up by
{{ field.label_tag }}.

Any help would be appreciated.

Thanks

akaariai

unread,
Mar 26, 2012, 10:21:16 AM3/26/12
to Django users
Using firebug I spotted this css for the label tag (Django 1.2
installation, might be different in more recent versions):
.aligned label {
display: block;
float: left;
padding: 3px 10px 0 0;
width: 8em;
}

So, you would probably want to override that (the width, especially)
in a custom css file. The documentation should contain the details of
how to do that.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/

- Anssi

Steven

unread,
Mar 26, 2012, 1:25:21 PM3/26/12
to Django users
I tried changing width from 8em to 16em in /usr/local/lib/python2.7/
dist-packages/django/contrib/admin/static/admin/css/forms.css in the
two places where it appeared:

.aligned label{
display: bloack;
padding: 3px 10px 0 0;
float: left;
width: 8em;
}

and

.inline-group .aligned-label{
width: 8em;
}

but to no avail. Is there someplace else I should be looking??
Reply all
Reply to author
Forward
0 new messages