It's more like, if a user tried logging into http://www.example.com he would be redirected to http://<username>.example.com.
Any simple ways to enforce this? Visually, the 2 links would be identical to the end-user (barring their login name somewhere) -Abraham V. On Thu, Feb 5, 2015 at 9:37 PM, Guilherme Leal <[email protected]> wrote: > I've made something similar. The app had multiple databases, and the > database that was connected was based on the subdomain of the request. > Basically, if you tried to log in with "http://test.exemple.com", the > database that would be used would be "test". > > The key to this feature was that the auth was on a separate db, and on > that db existed a profile table that indicates on wich database every user > would login. > > I think that it's kinda the inverse from what you need. > > Em Thu Feb 05 2015 at 13:59:34, mdj <[email protected]> escreveu: > >> If you're talking about ALLOWED_HOSTS, make sure you use something like >> ALLOWED_HOSTS = ['.example.com']. The dot is significant. >> >> You will also need to set SESSION_COOKIE_DOMAIN = '.example.com' so >> cookies work across subdomains. >> >> >> On Thursday, February 5, 2015 at 4:12:24 AM UTC-8, Abraham Varricatt >> wrote: >>> >>> Hello, >>> >>> I'm trying to implement custom subdomains on a customer site and am >>> having trouble understanding how the HOST option in settings.py works. The >>> requirement is that if a user logs in, they should see their own username >>> as the subdomain. So for example if we have 3 users - mark, alice and bob. >>> Now, if mark is logged in, he should interact with >>> http://mark.example.com . If alice is logged in, she should access >>> http://alice.example.com and so on. >>> >>> I've implemented this via custom middleware. What the middleware does >>> is; if whoever is accessing the site is a logged in user, check if they are >>> accessing the site via their respective subdomain entry. If not, prepend >>> their username to their request and issue a redirect to their web-browser. >>> The idea here is that if a logged in user (mark) tried to access >>> http://www.example.com/food/apple then he would be redirected to >>> http://mark.example.com/food/apple >>> >>> This works half-way. My users are able to login to the site, but for >>> some cases, where I need to call 3rd party APIs (and some jquery), things >>> aren't working as they should. It's kindof difficult to describe the issue, >>> but what I discovered is that in my settings.py file, if I set HOST= >>> mark.example.com , then the site works perfectly for user mark, but is >>> partly broken for the others. If I set HOST=alice.example.com, things >>> work perfectly for alice, but not anyone else. >>> >>> Does anyone have any good explanation for this behavior? Or should I be >>> trying a different approach? We're running django 1.5. >>> >>> Puzzled, >>> Abraham V. >>> >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/5d71e4bd-06ac-4d83-9d4a-a4e809d5024b%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/5d71e4bd-06ac-4d83-9d4a-a4e809d5024b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/NIEINxJQnM0/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAOs3Lp568ax2avSL5n3sUTLkJh0jBndcFYWstu_Pa8cpLBqkuw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAOs3Lp568ax2avSL5n3sUTLkJh0jBndcFYWstu_Pa8cpLBqkuw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADeSw2yMJEhzEvC3wxzrt%2Bas-zWcvpsDDdWTN7ebM-yLQEaTiw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

