Grappelli broken with latest Django trunk

1,293 views
Skip to first unread message

h3

unread,
Oct 23, 2011, 8:48:20 PM10/23/11
to Django Grappelli
I have a project where I needed to use GeoDjango with PostgreSQL and I
had to use Django trunk due to a bug in the database adapter for
Postgres 9+ which has been fixed[1] ..

But upgrading to django trunk (1.4 pre-alpha) broke a lot of
JavaScript things in Grappelli..

I tested with Grappelli 2.3.5 and master with the same results.

Here's the errors I get in the change_list:

> $("tr input.action-select").actions is not a function
> $("div#header .collapse").grp_collapsible is not a function

Almost nothing involving JavaScript works .. (action, filters,
ordering, etc..)

In the change_form I only get this error:

> $("div#header .collapse").grp_collapsible is not a function

Some things like the calendar works (even if the datetime widget is
pretty messed up), but most other things don't.

So far I've been able to track down only one difference between
Grappelli on django 3.1.* and django trunk..

When using django 3.1, this code block appars:

> <script type="text/javascript" src="/static/grappelli/js/core.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/admin/RelatedObjectLookups.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/jquery.min.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/jquery.init.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/actions.min.js"></script>
>
> <script type="text/javascript" src="/static/grappelli/js/SelectBox.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/SelectFilter2.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/calendar.js"></script>
> <script type="text/javascript" src="/static/grappelli/js/admin/DateTimeShortcuts.js"></script>

But most of those file are either blank file (to prevent 404) or are
overridden by grappelli's js files.

With django trunk they are not blank anymore, so jQuery gets loaded
twice and the old JavaScript files also gets loaded..

I tested with another project without GeoDjango with the same results.
So it's really a problem coming from Django core.

Those files are injected at the admin class level with the js Meta and
they are rendered in change_list.html at line 115 (well I think..)

https://github.com/sehmaschine/django-grappelli/blob/master/grappelli/templates/admin/change_list.html#L115

Technically since ADMIN_MEDIA_PREFIX points to the /grappelli/static/,
I don't know why django ends up looking in the /static/admin/ of the
contrib.admin for those files ..

In any cases, all this looks like a big hack that should be addressed
in django core first.. hardcoding js paths in the admin class doesn't
feels right and isn't flexible at all. It's also a guaranty that it
will break again in the future.

I was wondering if you guys were aware of this issue or if someone was
working to address it. If not I might give it a try.

[1] https://code.djangoproject.com/ticket/16778

h3

unread,
Oct 23, 2011, 11:59:07 PM10/23/11
to Django Grappelli
OK found the origin of the bug..

It seems that django trunk isn't honoring ADMIN_MEDIA_PREFIX anymore,
this might fixed
before 1.4, but from what I've seen in the source this settings will
be deprecated anyway so
we cannot rely on it.

Fortunately it's reasy to fix, you just have to rename grappelli/
static/grappelli/ to grappelli/static/admin/.
(a simple ln -s is the easiest quick fix right now..)

It's not fun but it works.. for everything except change_list "check
all" checkbox, which is still buggy.

So my suggestion is to create a branch or release 2.4 which will
rename the static/grappelli/ to static/admin for
django 1.4+.

I'll try to figure out what's wrong with the actions.js at some point,
but right now I must move on since I've
already lost quite a lot of time tracing back the source of this
problem..

regards
> https://github.com/sehmaschine/django-grappelli/blob/master/grappelli...

patrickk

unread,
Oct 24, 2011, 3:08:28 AM10/24/11
to django-g...@googlegroups.com
hi maxime,

our philosophy is to always develop grappelli against the latest official release. IMO it´s too early to take django 1.4 into consideration. I´m not exactly sure what Idan (Gazit) is doing with the admin in 1.4, but I guess that a lot of things will change.

best,
patrick

Klemens

unread,
Oct 24, 2011, 5:55:44 AM10/24/11
to django-g...@googlegroups.com

Klemens

unread,
Oct 24, 2011, 6:36:40 AM10/24/11
to django-g...@googlegroups.com
currently working on a project which needs some features from django's
trunk. thus i created a fork of grappelli on github
https://github.com/fetzig/django-grappelli

i already moved static/grappelli to static/admin and replaced "{%
admin_media_prefix %}" with "{{ STATIC_URL }}admin/". didn't forgot
the change_list bug you mentioned. will push a fix as soon as i need
it myself ;)

feel free to use the fork, and please send me pull requests to improve it.

regards,
klemens

patrick kranzlmueller

unread,
Jun 18, 2012, 6:59:32 AM6/18/12
to django-g...@googlegroups.com
grappelli 2.3.8 is not compatible with django 1.4 (see grappelli docs). version 2.4 will be (release coming soon, but you can take a look at the branch in the meantime).

best,
patrick


2012/6/18 Sergej Andrejev <sand...@gmail.com>
Sorry for excavation of old thread,

Was this fixed somehow. I just updated to grappelli 2.3.8 and django 1.4.0 and I have two jquery libraries loaded. First one from Grappelli is loaded then some functions are defined, but then django jquery overrides django.jQuery and all these function are lost. If it's in near releases I can wait, because the admin is working and there is not that much data yet to need all js function

Kind Regards,
Sergej

Brent O'Connor

unread,
Jun 18, 2012, 11:10:26 AM6/18/12
to django-g...@googlegroups.com
I've been using the 2.4 branch and it seems like it mostly works. The one issue that I've noticed is that you can't use the select drop down for doing actions (i.e. Delete) on multiple rows on the list display view. Any idea when "coming soon" will be?

- Brent

patrick kranzlmueller

unread,
Jun 18, 2012, 11:16:37 AM6/18/12
to django-g...@googlegroups.com
actions with selecting multiple rows works fine for us. please open a ticket with additional details ...

"coming soon" means next week (if no further tickets are being reported)!


2012/6/18 Brent O'Connor <br...@epicserve.com>

Brent O'Connor

unread,
Jun 18, 2012, 11:19:09 AM6/18/12
to django-g...@googlegroups.com
Awesome! I might need to update my local copy. I'll update it and if selecting multiple rows still doesn't work, I'll open a ticket.

-Brent

Sergej Andrejev

unread,
Jun 19, 2012, 7:53:14 AM6/19/12
to django-g...@googlegroups.com
So, for now on 2.3.8 I fixed javascript errors by creating MyWebsiteApp (already had it anyway) and created empty static/admin/js/jquery.init.js and  static/admin/js/jquery.js . That way django native jquery is not loaded because it's overridden by my empty js files. Don't know whether this breaks something, but so far everything seems to work fine

idea...@moculus.com

unread,
Nov 3, 2013, 9:51:05 PM11/3/13
to django-g...@googlegroups.com
I use django 1.5.1, django-grappelli 2.4.7.
I had the same error.

I removed staic/admin/js/jquery.* created by grappelli, then it's working now.
Reply all
Reply to author
Forward
0 new messages