Ticket #2500: pk-popup-close.diff

File pk-popup-close.diff, 849 bytes (added by deryck@…, 9 years ago)

String primary key values must be quoted or JavaScript assumes it's a variable.

  • django/contrib/admin/views/main.py

     
    263263                    post_url_continue += "?_popup=1"
    264264                return HttpResponseRedirect(post_url_continue % pk_value)
    265265            if request.POST.has_key("_popup"):
     266                # Quote if string, so JavaScript doesn't think it's a variable
     267                if type(pk_value) == str:
     268                    pk_value = "'" + pk_value + "'"
    266269                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
    267270                    (pk_value, str(new_object).replace('"', '\\"')))
    268271            elif request.POST.has_key("_addanother"):
Back to Top