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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/b0657dc4-d35c-4562-9f87-c276cfacf00c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to