Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter drop-down doesn't function due to Javascript error in Chrome, FF #12

Closed
ndrsn opened this issue Aug 1, 2011 · 31 comments
Closed

Comments

@ndrsn
Copy link

ndrsn commented Aug 1, 2011

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.

@sehmaschine
Copy link
Owner

did you try with django 1.3?

@ndrsn
Copy link
Author

ndrsn commented Aug 1, 2011

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!

@sehmaschine
Copy link
Owner

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.

@zettadam
Copy link

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.

@sehmaschine
Copy link
Owner

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

@zettadam
Copy link

Sorry, I read it too quickly :)

@sehmaschine
Copy link
Owner

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.

@user996015
Copy link

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

@sehmaschine
Copy link
Owner

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

@italomaia
Copy link

Is there a workaround for those using django1.4?

@maccesch
Copy link

I found one here: http://groups.google.com/group/django-grappelli/browse_thread/thread/7b929047d316275f

Haven't tried it though.

@user996015
Copy link

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

@Uznick
Copy link

Uznick commented Jun 1, 2012

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

@andrewkoltsov
Copy link

catch it with django 1.4.2 and grappelli 2.4.3

@vinyll
Copy link

vinyll commented Jan 4, 2013

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

@vinyll
Copy link

vinyll commented Jan 4, 2013

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>

@sehmaschine
Copy link
Owner

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?

@vinyll
Copy link

vinyll commented Jan 4, 2013

@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.

@sehmaschine
Copy link
Owner

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.

@defrex
Copy link

defrex commented Apr 11, 2013

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.

@ghost
Copy link

ghost commented May 8, 2013

ack. same issue as defrex

@benbarbour
Copy link

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.

@SeanHayes
Copy link

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)

@bjudson
Copy link

bjudson commented Aug 21, 2013

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.

@SeanHayes
Copy link

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

@backbohne
Copy link

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.

@samupl
Copy link

samupl commented Aug 2, 2015

Django==1.8.2
django-grappelli==2.7.1

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

@ghost
Copy link

ghost commented Feb 2, 2016

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.

@gameot
Copy link

gameot commented Mar 4, 2016

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/; }

@gasinvein
Copy link

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

@MohsenHassani
Copy link

MohsenHassani commented Jun 9, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests