Django-grappelli: Filter drop-down doesn't function due to Javascript error in Chrome, FF

Created on 1 Aug 2011  ·  31Comments  ·  Source: sehmaschine/django-grappelli

I just installed django-grappelli 2.3.4 in combination with Django 1.4.0 alpha. All's fine, except for the filter drop-down box on the change list page. Chrome and Firefox report a Javascript error:

Uncaught TypeError: Object #<Object> has no method 'actions'
(anonymous function):8000/admin/msdb/incident/:59
c.extend.readyjquery-1.4.2.min.js:26
L

The relevant bit of code is in templates/admin/change_list.html. A fix seems to be moving the block

{% if action_form %}
  ...
{% endif %}

from line 19 down to line 65, right after {{ media.js }}. I believe this is because the actions.js script is loaded in the block contained by media.js, which comes _after_ relevant Javascript code.

Not sure if this is a result of Django code still being in alpha, but figured I'd report it.

Another error occurrs at the same time by grp_collapsible in templates/admin/includes_grappelli/header.html:

Uncaught TypeError: Object #<Object> has no method 'grp_collapsible'

Don't know how to fix this one, though.

Most helpful comment

For me problem is still present.
python 2.7, django 1.9.6, grappelli 2.8.1

All 31 comments

did you try with django 1.3?

No, sorry. Just 1.4.0a. I'm a little groggy, but I believe it's mostly
a grappelli thing: the template change_list and the order of
loading/executing Javascript code.

I may have been a bit too hasty in filing the report, and not rigorous
enough in testing with different django versions -- apologies!

honestly ... I don´t think it´s a grappelli-error. otherwise hundreds of users won´t be able to use the filter drop-down and I don´t think that´s the case. I´m pretty sure it´s because of 1.4.0a ... and grappelli is always developed against the latest official release.

I can confirm that it is the case--the filter drop-down hasn't been working with django-trunk for quite some time. I haven't touched the Grappelli templates yet to move the code as swashbuckler suggested.

If Grappelli is kept up-to-date with django-trunk then it is an issue that should be looked at more closely. I suspect it has to do with Django 1.4 moving contrib.admin media to STATIC_URL and deprecating ADMIN_MEDIA_PREFIX.

if you read my last comment you'll see that grappelli is not developed with djangos trunk.

Sorry, I read it too quickly :)

I´m closing this ticket since it´s related to djangos trunk version. docs have been updated and a note has been added that grappelli is always developed against the latest stable django release.

It looks like this issue persists with 1.4 being released a few days ago. Any chance this could get fixed?

of course, it will get fixed once grappelli is compatible with django 1.4

Is there a workaround for those using django1.4?

for those using django1.4, use the grappelli_2_4 branch.

cd ../lib/python2.7/site-packages
git init django-grappelli
cd django-grappelli
git remote add --track grappelli_2_4 grappelli_2_4 https://github.com/sehmaschine/django-grappelli.git
git fetch grappelli_2_4
git checkout grappelli_2_4
python setup.py install

last time when I checked the branch there were huge problems with markup, that made most of it unusable in business :(

catch it with django 1.4.2 and grappelli 2.4.3

Using Grappelli 2.4.3 + Django 1.4.3 with Firefox 17 and having this error message on page having filters :

TypeError: $(...).actions is not a function
$("tr input.action-select").actions();

pagination bar broke-moved to top of list with filters not opening (see attached image).

Clearing cache does not help.

Capture d e cran 2013-01-04 a 11 50 42

Seems that the jquery used is not appropriate in my case (multiple versions are imported, scripts use "grp.jQuery" instead of default).
Fixed by overriding templates and replacing "grp.jQuery" with "django.jQuery" in the following code :

<script type="text/javascript" charset="utf-8">
        (function($) {
            $(document).ready(function() {
                $("tr input.action-select").actions();
            });
        })(grp.jQuery);
    </script>

That results in the following code :

<script type="text/javascript" charset="utf-8">
        (function($) {
            $(document).ready(function() {
                $("tr input.action-select").actions();
            });
        })(django.jQuery);
    </script>

grp.jQuery needs to be there, otherwise no js will work ... we already had that issue with another ticket and it turned out it´s been a setup issue. are you sure that your javascript-files are being loaded correctly?

@sehmaschine I updated my comment (using "django.jQuery" namespace instead of none).
grp.jQuery is actually 1.7.2 while django.jQuery is 1.4.2. I didn't customize of setup much in admin and grappelli. I might have missed some configuration setup somehow, but can't figure out what or where.

For information, here's my source file that fails. And where changing "grp.jQuery" to "django.jQuery" solves : https://gist.github.com/4452470

Even the check-all checkbox () works now.

can you check why grp.jQuery is not there? because it should be. as mentioned before, if grp.jQuery is not there, a lot of stuff won´t work as expected.

I'm having this same issue (Django 1.5, Chrome 26). If I break on the line in question ($("tr input.action-select").actions();), grp.jQuery is there, it just doesn't have the actions() method.

ack. same issue as defrex

I'm seeing the same thing as you, @defrex, but only when actions.min.js is loaded. If DEBUG=True everything seems fine. Have your @vongesell noticed that as well? Did either of you manage to fix it?

Oh yes, same version of Django and Chrome, and I'm using grappelli 2.4.4.

Same issue, Django==1.5, django-grappelli==2.4.4, Firefox 22.0 on Ubuntu. Firebug console output:

TypeError: $(...).actions is not a function
[Break On This Error]

$("tr input.action-select").actions();

/api/a...kstate/ (line 55)

Also seeing it here. In my case, the Grappelli version of actions.js was not copied into /static/admin/js/ by collectstatic. All I had to do was copy it manually and everything works. Had the same problem with prepopulate.js.

@bjudson Thanks for the hint. For me it turned out collectstatic didn't copy everything over. I ran it again and now everything works.

Same issue with Django 1.6 and Grappelli 2.5.0. Patching ../grappelli/templates/admin/change_list.html like recommented by Vinyll fixes my problems.

Django==1.8.2
django-grappelli==2.7.1

Problem still persists, collectstatic doesn't find grappellis admin/ static folder for some reason.

Django==1.8.3
django-grappelli==2.7.3

problem still here for me

~django.contrib.admin.options.ModelAdmin#media:635
if self.actions is not None:
js.append('actions%s.js' % extra)

If you do something in a ModelAdmin subclass that prevents this method (property) from getting called, like redefine the media property without calling this super one, then you don't get actions loaded. And you also don't get the extend feature of Form.media. So, even if you try to put actions in your class Media in the subclass it doesn't get found.

So, put a check point in that method and make sure it's getting called.

I had the same problem and I solved it by editing nginx config.
Before:
location /static/admin/ { alias /web/merv/env/lib/python3.4/site-packages/django/contrib/admin/static/admin/; }
location /static/ { alias /web/merv/files/static/; }
After:
location /static/ { alias /web/merv/files/static/; }

For me problem is still present.
python 2.7, django 1.9.6, grappelli 2.8.1

For solving the problem I needed to comment the /static/admin/ block in the nginx config file of the website (as @gameot said); like this:

#location /static/admin/ {
#   alias /home/mohsen/virtualenvs/django-1.9/lib/python3.4/site-packages/django/contrib/admin/static/admin/;
#}

I could delete it of course! It just seems to be useless when using grappelli.

After that do the collectstatic as grappelli docs says: python manage.py collectstatic
Then restart nginx.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karansag picture karansag  ·  55Comments

adamchainz picture adamchainz  ·  24Comments

asfaltboy picture asfaltboy  ·  11Comments

johncpang picture johncpang  ·  4Comments

FrozenAlex picture FrozenAlex  ·  15Comments