Skip to content Skip to sidebar Skip to footer

Find Host And Port In A Django Application

I'm connecting to the Twitter Streaming API and am setting up the OAuth handshake. I need to request a token and send a callback_url as a params dictionary along with post request

Solution 1:

call request.build_absolute_uri(), then extract the domain.

docs:

HttpRequest.build_absolute_uri(location) Returns the absolute URI form of location. If no location is provided, the location will be set to request.get_full_path().

If the location is already an absolute URI, it will not be altered. Otherwise the absolute URI is built using the server variables available in this request.

Example: "http://example.com/music/bands/the_beatles/?print=true"

Post a Comment for "Find Host And Port In A Django Application"