-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove dependency on django.contrib.sites
#11
Comments
can be implemented as soon as how i decide how i want to declare the setting |
Future changes after 2a5ea16 have moved get_domain() into utils.py - how would I go about overriding it now? If I subclass SubdomainURLRoutingMiddleware and change get_domain_for_request, the call in utils.py's reverse() is still unchanged. |
Any update on this? I've implemented my own middleware to lose the dependency, but in order to use the subdomain reverse method I still need the dependency. Would love to help out. |
@AndreasBackx I know this is an old topic, but is there any chance you can detail how you were able to remove the dependency on Site? I can't seem to figure out what exactly I need to add to settings.py to get this middleware to stop throwing errors with it. |
@alex-polosky I inherited from the default middleware and overrode the part where it normally calls out to from subdomains.middleware import SubdomainURLRoutingMiddleware
class SubdomainHostMiddleware(SubdomainURLRoutingMiddleware):
"""Django-subdomains middleware implementation with no dependency on django.contrib.sites."""
def get_domain_for_request(self, request):
# Return the host without the port
host = request.get_host().split(':')[0]
domains = host.split('.')
domain = '.'.join(domains[1:] if len(domains) > 2 else domains[:2])
return domain domain = '.'.join(domains[1:] if len(domains) > 2 else domains[:2]) Let's say the host is |
@AndreasBackx awesome, works like a charm. Thanks so much! Also gives me a starting point on how to further configure it for my needs. |
Has anyone figured out how to remove the dependency on Site in the reverse method? |
No description provided.
The text was updated successfully, but these errors were encountered: