Skip to content

Instantly share code, notes, and snippets.

@develmaycare
Created March 22, 2011 18:34
Show Gist options
  • Save develmaycare/881765 to your computer and use it in GitHub Desktop.
Save develmaycare/881765 to your computer and use it in GitHub Desktop.
A simple recipe for getting the virtual host name from within a Django view using RequestSite.
from django.contrib.sites.models import RequestSite
from django.shortcuts import render_to_response
def my_view(request):
domain = RequestSite(request).domain
# ... do some domain specific things here ...
return render_to_response("my_view.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment