Django admin add related object doesn't open popup window?

1,385 views
Skip to first unread message

j.coss...@gmail.com

unread,
Oct 22, 2015, 10:48:14 AM10/22/15
to Django users

I already posted this question on Stackoverflow (http://stackoverflow.com/q/33189728/855050), but haven't received any answers, just a comment by another user with the same issue. I am posting here for added visibility. I think this is a bug in Django v1.8. I'll copy the question's text here for convenience.


The django-admin app is supposed to open a popup window when I try to create a related object. For example, clicking the green plus button here:






Should bring a new pop-up window, where I can create a new related (in this case Session) object. However, when I click the green plus button, the object create opens up in the same window, instead of a pop-up window. This is a problem, because if a user starts to create a primary object, then half-way through, clicks the green plus, he will lose all the progress on the primary object. This means that the green plus is unusable.

I have no idea why this is happening. Any ideas of how I can diagnose this? And fix it?



Related: http://stackoverflow.com/q/29811544/855050. But he's using Grappelli, which I am not. I am using the default django admin interface.

I am using Django version 1.8.

PD: In the meantime, is there a way to disable the popups? Right now this feature is broken in my server and its affecting my users.

Derek

unread,
Oct 24, 2015, 2:57:23 AM10/24/15
to Django users
Disable the popup ... a suggestion was made in  https://code.djangoproject.com/ticket/9071 which is:

class ProductAdmin(ModelAdmin):

    def get_form(self, request, obj=None, **kwargs):
        """
        Don't allow adding new Product Categories
        """
        form = super(ProductAdmin, self).get_form(request, obj, **kwargs)
        form.base_fields['category'].widget.can_add_related = False
        return form
Message has been deleted

j.coss...@gmail.com

unread,
Oct 27, 2015, 11:18:18 AM10/27/15
to Django users
Thanks, I succesfully disabled the add related button, as a temporary patch.

Any ideas of why the pop-up isn't working?

Tim Graham

unread,
Oct 27, 2015, 11:32:33 AM10/27/15
to Django users
Please check the JavaScript console in your browser to see if there are any errors.

Jorge Fernandez-de-Cossio-Diaz

unread,
Nov 19, 2015, 8:32:32 AM11/19/15
to Django users
I pressed F12 on Firefox, and played around to see if I could find anything. But I didn't see anything that looked like an error. But I'm not sure what I am looking for. What else can I do?

Tim Graham

unread,
Nov 19, 2015, 9:13:01 AM11/19/15
to Django users
Yes, it would be in the "Console" tab of that window. You need to open console using F12 first, then trigger the action. If you can create a minimal project that reproduces the error, then other people can try to reproduce it as well.

Jorge Fernandez-de-Cossio-Diaz

unread,
Nov 19, 2015, 11:48:41 AM11/19/15
to Django users
I'm trying to isolate a small example of the error, but I still haven't quite diagnosed the problem. I appreciate your help. This what I get in the "Console" tab:


GET
http://192.168.101.10:66/it_meeting/admin/it_meeting_profiles/institute/126/ [HTTP/1.1 200 OK 771ms]
GET
http://192.168.101.10:66/static/admin/css/base.css [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/css/forms.css [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/it_meeting/admin/jsi18n/ [HTTP/1.1 200 OK 17ms]
GET
http://192.168.101.10:66/static/admin/js/core.js [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/js/admin/RelatedObjectLookups.js [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/js/jquery.js [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/js/jquery.init.js [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/js/actions.js [HTTP/1.1 200 OK 0ms]
GET
http://192.168.101.10:66/static/admin/css/widgets.css [HTTP/1.1 200 OK 0ms]
reflow: 0.2ms
reflow: 0.45ms
reflow: 0.06ms function <anonymous>, jquery.js line 1574
reflow: 0.27ms function <anonymous>, jquery.js line 1574
reflow: 0.13ms function <anonymous>, jquery.js line 1581
reflow: 0.05ms function <anonymous>, jquery.js line 1596
reflow: 0.19ms function <anonymous>, jquery.js line 1596
reflow: 0.21ms function <anonymous>, jquery.js line 1628
reflow: 0.1ms function <anonymous>, jquery.js line 1636
reflow: 0.11ms function <anonymous>, jquery.js line 1642
reflow: 0.06ms function <anonymous>, jquery.js line 1647
reflow: 0.17ms

Jorge Fernandez-de-Cossio-Diaz

unread,
Nov 20, 2015, 8:10:10 AM11/20/15
to Django users
Is there another test I can do?

Jorge Fernandez-de-Cossio-Diaz

unread,
Nov 22, 2015, 1:36:29 PM11/22/15
to Django users
UPDATE: The admin popups work fine with `manage.py runserver`. The are broken only in the deployed project with apache2. Note that I did not change any setting between both deployments. I hope this narrows it down.

Jorge Fernandez-de-Cossio-Diaz

unread,
Nov 22, 2015, 3:37:48 PM11/22/15
to Django users

I wasn't able to produce a minimal example of what was going on, but it is fixed now. Essentially, I did the following:

  1. Upgraded to Django 1.8.6 .
  2. Ran python manage.py collectstatic (as suggested in https://community.webfaction.com/questions/18544/there-is-not-popup-window-for-one-to-many-relationship-with-djangos-admin-v18)

I hope this is useful to someone else.

Reply all
Reply to author
Forward
0 new messages