views:

31

answers:

2

I have a Django admin action called "Email selected members". Check some members and click the Go button and the user's mail program is opened. The emails of the selected members have been pre-entered.

This works by a Django HttpResponseRedirect(uri) with the uri being "mailto:email1,email2.. where the addresses email1, email2 ... were looked up on the server.

The only problem is that that the browser re-directs to a blank page as well a opening the client mail program.

Is there any way to avoid this?

-- Peter

+1  A: 

Don't use HttpResponseRedirect. Just make the mailto: line a link. <a href="mailto:email1...">Email selected members</a>

controlfreak123
I guess it is not Peter's intention to have somebody click on a link!
lazerscience
well i should have known. It seems like its all the rage lately for one-off users to post answers and then not even comment or do anything with it.
controlfreak123
Yes, controlfreak it may be, which is a shame that. But a chap has to sleep. As lazerscience says I don't want to write client side code into a custom Django admin form.
Peter2108
well I would say that if you are getting a blank page on a response redirect then that is pretty much a browser specific thing. I get blank pages every once in awhile when i click on attachments to download them in emails. Its probably a very similar thing. Even if you do a response redirect with mailto in it mailto is a client side action. Why do you think it opens up the default email client?
controlfreak123
A: 

I don't think it is possible. RFC 2616 says re 302 redirect:

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s)

So the blank page that I see is the (very) short hypertext note. The browser gets the redirect instruction, pops up a temporary page with the redirect message, then retrieves the redirected URL. But with a mailto: URL the temporary page obviously remains.

Peter