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