Thank you to all whohave replied.

I will give the sites framework an honest effort and solve my problem.

Thank you very much for your time and effort. :-)

Nanda

On Jul 19, 2:42 pm, jaymzcd <jaym...@googlemail.com> wrote:
> Like Daniel & Steve have said already, urls.py only deals with the
> path component of the URL, not the domain. The sites framework is what
> you need to use, its pretty simple. All you really need to do is
> something like:
>
> 1. in urls.py match the URL you want that is common for both
> subdomains
> 2. in your view for that pattern get the current site id
> 3. based on what subdomain (site) is returned execute the appropriate
> function
>
> urls.py *cant* know about the subdomain.  If you have an aversion to
> using the sites framework you could maybe hack it to work by looking
> at the contents of request.META['SERVER_NAME'] in your view but i
> wouldnt do that. Check the sites framework...
>
> jaymz
>
> On Jul 19, 7:05 am, nandu <navanitach...@gmail.com> wrote:
>
> > Thank you to all who have replied to my query.
>
> > I do not think I need to use the sites framework because my subdomains
> > are not on different servers and hence are not really different sites.
> > Possibly what I am working with are actually pseudo-subdomains and not
> > subdomains in the real sense. I will explain what I am intending to do
> > below:
>
> > Let us say that I have a domain "example.com"
>
> > This site contains subdomains like the following:
>
> > subdomain1.example.com
> > subdomain2.example.com
>
> > and so on.
>
> > In my urls.py if I want to map the subdomain1.example.com to some
> > function and I need to know what regular expression I should use.
> > Another problem I am facing is that I testing this on localhost so I
> > need to get a URL that I believe looks like "subdomain1.127.0.0.1:
> > 8000" instead if "127.0.0.1:8000/subdomain1" and get urls.py to
> > recognise this. I know that I may need to write a middleware class
> > that intercepts every URL which I have implemented but I have no idea
> > how to specify the URL in my href attribute in my link.
>
> > so that it is taken as subdomain1.127.0.0.1: 8000 instead of
> > 127.0.0.1:8000/subdomain1 which is incorrect.
>
> > FYI
> > I am working on a Ubuntu Linux machine and the Django development
> > server.
>
> > I am sorry if I have misunderstood your answers above but IMHO I do
> > not think I need to use the sites framework as this is a fairly simple
> > thing.
>
> > Thank you.
>
> > Yours sincerely,
> > Nanda
>
> > On Jul 18, 1:47 am, Steve Holden <holden...@gmail.com> wrote:
>
> > > On 7/17/2010 12:38 PM, nandu wrote:
>
> > > > Dear Folks,
>
> > > > After researching the topic of using subdomains with Django I have
> > > > found that it is does not seem to be a straight forward thing to do.
>
> > > > I have also found many websites showing methods of how to do this, but
> > > > there is one aspect that none of them seem to explain. That is how
> > > > does one specify the URL for the subdomain in urls.py if I had a
> > > > subdomain like "something.example.com".
>
> > > > I would also appreciate it if someone could point me in the right
> > > > direction in terms of how to use subdomains with django as each
> > > > website seems to specify a different method, and I have no idea which
> > > > one is the best. The URLs of the websites I have looked at are below:
>
> > > >http://uswaretech.com/blog/2008/10/using-subdomains-with-django/
>
> > > >http://thingsilearned.com/2009/01/05/using-subdomains-in-django/
>
> > > >http://www.nerdydork.com/django-accounts-on-subdomains.html
>
> > > >http://djangosnippets.org/snippets/1119/
>
> > > > I am also looking for a solution that avoids making many changes to
> > > > the web application when it is about to be deployed.
>
> > > > Please forgive my ignorance in this matter.
>
> > > Servers in different subdomains are different sites, so you may want to
> > > read up about Django's sites framework.
>
> > >    http://docs.djangoproject.com/en/dev/ref/contrib/sites/
>
> > > regards
> > >  Steve
> > > --
> > > Steve Holden           +1 571 484 6266   +1 800 494 3119
> > > DjangoCon US September 7-9, 2010    http://djangocon.us/
> > > See Python Video!      http://python.mirocommunity.org/
> > > Holden Web LLC                http://www.holdenweb.com/
>
> > > --
> > > Tel/Toll-free:       +1 571 484 6266     +1 800 494 3119
> > > DjangoCon US September 7-9, 2010    http://djangocon.us/
> > > See Python Video!      http://python.mirocommunity.org/
> > > Holden Web LLC                http://www.holdenweb.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to