[BangPypers] Can two django projects be made to communicate to each other

Lakshman Prasad scorpion032 at gmail.com
Wed Dec 1 13:29:02 CET 2010


If you have 2 base urls.py, I think correspondingly, you also need 2
settings.py and hence 2 WSGI files.

As far as I know, each Apache virtualhost can only take 1 WSGIProcess. So
you will need 2 apache processes. - I might be wrong on this, and there
might be a better way.

The best way, I can think of to move the request around between projects
(and corresponding apache processes) would be to use nginx as a proxy and
pass the request to an appropriate process.

There are many good tutorials to configure nginx to proxy apache. You should
refer:
http://www.ventanazul.com/webzine/tutorials/django-deployment-guide-ubuntu

<http://www.ventanazul.com/webzine/tutorials/django-deployment-guide-ubuntu>But
I wonder why you want to have 2 urls.py and 2 settings.py *within the same
repo*. Sounds counter intuitive to me. Is there a reason you cant refactor
it into the same urls.py with includes like:

urlpatterns = patterns('',
    (r'^weblog/',        include('django_website.apps.blog.urls.blog')),
    (r'^documentation/', include('django_website.apps.docs.urls.docs')),
    (r'^comments/',      include('django.contrib.comments.urls')),)



On Wed, Dec 1, 2010 at 5:36 PM, Anubha Dadhich <sethi.anubha at gmail.com>wrote:

> On Wed, Dec 1, 2010 at 5:16 PM, Lakshman Prasad <scorpion032 at gmail.com
> >wrote:
>
> > If I understand what you are saying,
> >
> > You have 2 different projects in django, (in different repos) and you
> don't
> > want to have user logged in, in each site.
> >
>
> They are in the same repository. Yes we do not want user to log in at both
> the places.
>
> >
> > The *simplest* way to solve this is to configure the django.contrib.auth
> of
> > both the projects to use the same database. - And yes, it is a goddamn
> > database. Any number of separate projects can open connections to it.
> >
>
> Yes the two projects are sharing the same database.
>
>
> > Details about using multiple databases in projects can be found in the
> > documentation:
> >
> >
> http://docs.djangoproject.com/en/dev/topics/db/multi-db/#defining-your-databases
> >
> > <
> >
> http://docs.djangoproject.com/en/dev/topics/db/multi-db/#defining-your-databases
> > >Essentially
> > you will need to define the routers and for this case, the router is just
> a
> > lambda that gives the user database if the app is django.contrib.auth.
> >
> >
> >
> The problem is that I do not understand how to make apache redirect
> requests
> to their respective projects.
>
> Say the projects, project1 and project2, have their respective urls.py
> file.
>
> When the url is www.test.com/account/login --  the request should be
> redirected to project1, because only the urls file in the project1 knows
> how
> to resolve it.
>
> as the url changes to www.test.com/profile -- the request should be
> redirected to project2. (say profile requires user to be authenticated,
> then
> as you and siddharta mentioned that user authentication is taken care by
> django.contrib.auth backend and the two projects are already sharing the
> same database, there should not be any problem in passing the user_context
> between the two projects).
>
> I need some links which will help me configure apache in the desired way.
> That will help a great deal.
>
>
> Thanks all.
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list