Actually, never mind, I was able to work around the problem be redefining hurry.
On Oct 20, 2016 2:47 AM, "Derek" <[email protected]> wrote: > The article linked to is from 2008 - have some things not changed in > Django since then? > > On Friday, 14 October 2016 15:22:12 UTC+2, David wrote: >> >> Hi Giuseppe, >> I was upgrading to a later version of django and ran into the same issue. >> Did you find a work-around? >> >> On Wednesday, April 27, 2016 at 11:37:19 AM UTC-7, Giuseppe wrote: >>> >>> I managed to get this working, sort of. I learned that I need to include >>> jquery.init.js to my parent form. otherwise It wont open in a new window. >>> Now the only issue I am encountering is after I submit my child form, the >>> window goes white, but does not close. I think the code that gets called >>> when I submit the form is this >>> return HttpResponse('<script type="text/javascript">opener. >>> dismissAddRelatedObjectPopup(window, "%s", "%s");</script>' % \ >>> (escape(newObject._get_pk_val()), escape(newObject))) >>> I cant figure out if its being called at all or if its being called on >>> the child or if its being called on the parent and thats why its not >>> closing. "window" is being staticaly typed so its not in the view code >>> other than that one spot. >>> >>> Here is the Django code for the dismiss function (this was pulled >>> directly from https://github.com/django/dja >>> ngo/blob/master/django/contrib/admin/static/admin/js/admin/ >>> RelatedObjectLookups.js >>> function dismissAddRelatedObjectPopup(win, newId, newRepr) { >>> var name = windowname_to_id(win.name); >>> var elem = document.getElementById(name); >>> if (elem) { >>> var elemName = elem.nodeName.toUpperCase(); >>> if (elemName === 'SELECT') { >>> elem.options[elem.options.length] = new Option(newRepr, >>> newId, true, true); >>> } else if (elemName === 'INPUT') { >>> if (elem.className.indexOf('vManyToManyRawIdAdminField') >>> !== -1 && elem.value) { >>> elem.value += ',' + newId; >>> } else { >>> elem.value = newId; >>> } >>> } >>> // Trigger a change event to update related links if >>> required. >>> $(elem).trigger('change'); >>> } else { >>> var toId = name + "_to"; >>> var o = new Option(newRepr, newId); >>> SelectBox.add_to_cache(toId, o); >>> SelectBox.redisplay(toId); >>> } >>> win.close(); >>> } >>> >>> I can see that after I submit my new object gets selected in the >>> dropdown inside the parent form, but the popup window from the child form >>> does not close. Any ideas how to get the child form to close, the dismiss >>> function should be doing that correct? >>> >>> >>> On Wednesday, April 20, 2016 at 5:06:22 PM UTC-4, Giuseppe wrote: >>>> >>>> I am trying to get a pop up that will let me create a new object to >>>> associate to a many to many relationship on a form/model. In the same way >>>> that it works in django-admin. >>>> >>>> I have been followed the instructions from here >>>> <http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/>, and >>>> its not working for me. >>>> >>>> whenever I click the plus button it opens the related object creating >>>> form in the same tab instead of a new pop up. When I try to submit the new >>>> object I get a cert error and I included the cert tag in the template. >>>> >>>> Let me know what code you want to see and I can post it. Also if you >>>> know of a different resource, or library or way of doing this that would be >>>> amazing. >>>> >>>> By the way I think the link provided was for django 1.1 and im using >>>> django 1.9.1 >>>> >>> -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/django-users/2XIgnW4sEHk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/45d0262c-fd2c-4b65-9353-0e7194fe2e0e%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/45d0262c-fd2c-4b65-9353-0e7194fe2e0e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGNQvMOPXLvJrntmiEOuNiHVqDSmLhGUG5YubBqEUuV1%3DQjhRQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

