0

I'm using django for the first time. I've experience with python but not with web development. Now I'm trying to design an admin page with grappelli. Only grappelli doesn't show the tables full screen (column width too small) and it looks horrible. Only a third of my screen is used. Is there a way to set the column width keeping the users screen size in mind. It look somewhat like this only worse. I can' t post any of the real data since it' s for scientific purposes. I tried to fins the answer as well but couldn't find any that work for me. I'm using django 1.10, python 2.7 and grappelli 2.8.2. The reason I'm using grappelli is because of the drop down filter. If anyone knows how to make a drop down filter in django that' s also fine by me.

Grapelli interface:

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Dani
  • 55
  • 5

1 Answers1

0

Try this one, or this one. They are describing how to change the width of your columns in django admin.


EDIT

Install your virtual environment only for your project. if you do not have installed virtualenv in your main pip execute:

pip install virtualenv

then create your virtual environment just for your project with:

  1. virtualenv env
  2. Activate just created env with: source env/bin/activate
  3. Install your dependencies like django or grappelli pip install django pip install django-grappelli
  4. Now you can find your files inside newly created env

EDIT 2

If you want to add your custom styles to your template, there is a block which basically looks like this:

{% block stylesheets %}
    {{ block.super }}
    {{ media.css }}
{% endblock %}

So if you want to add your custom css, just add path to your .css file. Or simply make custom css like this:

{% block stylesheets %}
    {{ block.super }}
    {{ media.css }}
    <style> 
        .column-your_columns_name {
            width: 500px;
        }
{% endblock %}

note that, every column can be accessed by class. Each column class is always named column-fieldname. So for example, if you have a column named price (column names are taken from models) you can access it in your styles by:

.column-price{}

Community
  • 1
  • 1
sebb
  • 1,956
  • 1
  • 16
  • 28
  • I can' t seem to get the first one to work the change list.html is now using css and i can' t find it anywhere on my system. The other one i simply don' t understand. It doesn' t seem to have an answer. Only to create a static css file but it doens't tell how or where. Because i tried to do that but i didn' t work because i simply don' t knwo how to get it to work – Dani Sep 29 '16 at 07:40
  • The first one is located in your virtual environment. so assuming your environment is here `/home/yourapp/env/` - your change_list.html will be located in `/home/yourapp/env/lib/python/site-packages/grappelli/templates/admin/change_list.html` - note that you can also add your custom css files to that html file. – sebb Sep 29 '16 at 07:44
  • I have looked in usr/lib/python2.7 but there is no site packages folder. I also looked in usr/local/lib/python2.7 and there is only an empty site-packages folder there. And there is nothing in myapp folder as well – Dani Sep 29 '16 at 07:50
  • Where did you install grappelli package ? – sebb Sep 29 '16 at 07:53
  • I don't know used pip install django-grappelli. So i thought somewhere in python but can' t find it in my library – Dani Sep 29 '16 at 07:54
  • That worked thank you. Now i don' t know where to add the css... The django and webdesign structure is like algebra to me. I'm sorry for my inexperience. – Dani Sep 29 '16 at 08:12
  • Marks as an answer then. Best wishes – sebb Sep 30 '16 at 07:39