There is a potential error with the solution provided by Daniel, see this Django ticket . That is, if you use application/xhtml, then the window will not be closed if you return only the script. This error has since been fixed, although in Django.
<!DOCTYPE html>, Django :
'<!DOCTYPE html><html><head><title></title></head><body>'
'<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script></body></html>' % \
# escape() calls force_unicode.
(escape(pk_value), escapejs(obj)))