This is not exactly how the Sites framework works. To differentiate between sites using the sites framework, every site must have its own settings module (because that's where you set the SITE_ID
).
What you are looking for is a way to get the current site from the request. You could use the RequestSite
object for this:
from django.contrib.sites.models import RequestSite
site_name = RequestSite(request).domain
There's also django-dynamicsites which does the same thing with a few more extras (redirects, template/url assignment, ...)