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

Add another popup doesn't add ?_popup=1 to url in Django 1.8 #118

Closed
vil-s opened this issue Apr 13, 2015 · 8 comments
Closed

Add another popup doesn't add ?_popup=1 to url in Django 1.8 #118

vil-s opened this issue Apr 13, 2015 · 8 comments
Labels

Comments

@vil-s
Copy link

vil-s commented Apr 13, 2015

Using the included example, when adding a Song object at http://localhost:8000/admin/example/song/add/, there is a field for selecting a Group foreign key with a "+ add" link next to it.

In Django < 1.8, when clicking on the link, a popup opens with the url http://localhost:8000/admin/lookups/add_popup/example/group?_popup=1 and when saving the Group, the popup closes and the Group field is populated in the Song form.

However in Django >= 1.8 the popup url is http://localhost:8000/admin/lookups/add_popup/example/group (note the missing ?_popup=1) and when saving the Group, the popup redirects to the Group and doesn't populate the Song form's Group field.

Presumably some admin javascript changed in the Django 1.8 update, but I haven't yet tracked it down.

EDIT: It looks like the showAddAnotherPopup/showRelatedObjectPopup has changed and it no longer adds the _popup parameter

@crucialfelix
Copy link
Owner

That must be why it doesnt close itself and set the pk correctly. I noticed
this with 1.8 but didn't file the bug yet.

There are unit tests now so I hope to corner these annoying breakages and
keep it maintainable.
On Apr 13, 2015 11:45 AM, "unklphil" notifications@github.com wrote:

Using the included example, when adding a Song object at
http://localhost:8000/admin/example/song/add/, there is a field for
selecting aGroup` foreign key with a "+ add" link next to it.

In Django < 1.8, when clicking on the link, a popup opens with the url
http://localhost:8000/admin/lookups/add_popup/example/group?_popup=1 and
when saving the Group, the popup closes and the Group field is populated
in the Song form.

However in Django >= 1.8 the popup url is
http://localhost:8000/admin/lookups/add_popup/example/group (note the
missing ?_popup=1) and when saving the Group, the popup redirects to the
Group and doesn't populate the Song form's Group field.

Presumably some admin javascript changed in the Django 1.8 update, but I
haven't yet tracked it down.


Reply to this email directly or view it on GitHub
#118.

@splatEric
Copy link

I think the problem might be around detecting when an object is selected - I get the popup working fine, but when add_popup in the views tries to inspect the response text to look for dismissAddAnotherPopup it doesn't find it - I think the response model might have changed. No time to dig further now, but thought it might be useful to pass on

admin.add_view is returning a redirect response because it no longer has the _popup query string value in it. I've got a bit of a dirty hack to resolve this which basically entails:

  1. manipulate the GET and POST to include _popup=1
  2. change the javascript function call replacement to swap out dismissAddRelatedObjectPopup for didAddPopup

@splatEric
Copy link

This change seems to fix the problems with this functionality, but it might be a bit of a dirty hack, rather than the actual solution you want to go with:

splatEric@f946a0a

But if you're happy to bring it in, let me know and I'll send over the pull request.

@riklaunim
Copy link

Would be good to have Django 1.8 support.

@riklaunim
Copy link

So where is django-ajax-selects now? I see a lot of commits but no new release with Django 1.8/Py3.X support.

@crucialfelix
Copy link
Owner

The development branch has full support and I'm working on the release today

The previous release 1.3.6 supports Django 1.8 but with a deprec warning. Django 1.9 beta would not work, but it does work with the impending release.

Python 3 has been supported for many versions but one commit broke that. Now the tox tests check all pythons up to 3.5

@riklaunim
Copy link

nice :)

@crucialfelix
Copy link
Owner

1.4.0 came out on Sunday. Sorry I forgot to announce here.

Check the docs, they are I think much better. Configuration is easier than
ever too thanks to autodiscovery.

On Mon, Nov 2, 2015 at 10:52 AM Piotr Maliński notifications@github.com
wrote:

nice :)


Reply to this email directly or view it on GitHub
#118 (comment)
.

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

No branches or pull requests

4 participants