Module Columns the other way.

Issue #18 resolved
Klemens Mantzos
created an issue

patrickk and I worked on implementing grappelli as theme for the dashboard.

one thing for shure: we overloaded/overwrote a bunch of templates to get the grid/grappelli layout working.

but there is something we would like to see in the model. i refactored the way dashboard is working with the columns, and made a new DashboardModule subclass.



class DashboardModuleColumn(DashboardModule):

def __init__(self, **kwargs):
    super(DashboardModuleColumn, self).__init__(**kwargs)
    self.title = kwargs.get('title', '')
    self.template = kwargs.get('template',
    self.children = kwargs.get('children', [])
    self.className = kwargs.get('className', [])


and config in custom dashboard:



self.children.append(DashboardModuleColumn( title=('col 1'), className="span-12", children=( DashboardModuleGroup( title=('Group Name'), list=( SortedModelListDashboardModule( title=('User Management'), list=( 'django.contrib.auth.models.User', 'grtest.models.SomeModel', ), ), SortedModelListDashboardModule( title=('User Management'), list=( 'django.contrib.auth.models.User', 'grtest.models.SomeModel', ), ), ), ), ), )) }}}

(personally I think there are many ways to make this work. but this was the fastest and seemed to be the easiest for the moment.)

thus we need to edit the dashboard.html because the dashboard.children changed. maybe we can avoid this to reactor this someway else (i.e. with a different templatetag)



{% for column in dashboard.children %} <div class="column {{ column.className }}"> {% for module in column.children %} {% admin_tools_render_dashboard_module module forloop.counter %} {% endfor %} </div> {% endfor %}


this (or something like it) is all we need to get grappellis admin startpage working as theme of admin-tools. i think ;)

hope you like it and/or have some feedback.

greetings, klemens

Comments (9)

  1. David Jean Louis repo owner

    Hey fetzig, patrickk,

    I'm really not sure about this, it complicates a lot the dashboard api IMO.

    Not sure what solution we could implement, maybe something optional ? i mean some switch to force dashboard columns if you want to, but definitively not by default.

    I'll investigate more on possible solutions when I'll have more free time.

    I like a lot the DashboardModuleGroup idea though, this will go in ASAP.



  2. sehmaschine

    yes, this should be optional.

    I do agree that it looks a bit complicated. however, you´re doing that only once when setting up the dashboard. and the structure is very flexible (changing from 2 to 3 columns is a matter of seconds). with having a grid-based layout, different modules get different importance (depending on the column they´re in). IMHO, this is needed most of the time since modules are not equally important (e.g. an "app-list" is probably more important than "recent actions").

    btw: it´s not needed to integrate this in order to make admin-tools compatible with grappelli. we could also extend grappelli to include a grid-based dashboard.

  3. Klemens Mantzos reporter

    hi guys,

    was updating my fork of admin-tools (

    so here the changes (compared to current original head) to get feedback from you:

    - added a column property to DashboardModule() (default = 1) to check in the dashboard.html in what column the module should be rendered. This is the easiest way to get this feature (IMO).

    - added the column property to the dashboard.txt to get grappelli compatible's immediatly

    - customized most of the html templates to be analog to grappelli's grid layout


    kthxby, klemens

  4. David Jean Louis repo owner
    • changed status to open

    Hi klemens,

    Glad to see you're still working on this ! The column property is a good idea.

    I can't pull your changes as is though.

    Can you please start over with a clean fork and provide a changeset that *only* include the needed changes, without any whitespace modifications and without removing css/js includes (why did you this btw ? ).

    Whitespace is important as it makes easy to keep the templates sync with django (with vimdiff), I don't want to change this.

    So in short, +1 for your changes with a clean patch ;)


    -- David

  5. Log in to comment