Django – Different URLs for Production and Development

djangourl

Is it possible to have two different urls.py files for one project, using one of them all the time, but then invoking the second for development purposes?

What I want is this:

For production (and is live 24/7) I want the following links:

www.mydomain.com
www.mydomain.com/about/
www.mydomain.com/contact/

But for development (which I use the runserver now and then as I test) I want all the base links, plus a few more:

www.mydomain.com
www.mydomain.com/about/
www.mydomain.com/contact/
www.mydomain.com/secret/sauce/
www.mydomain.com/punchanella/in/the/zoo/
www.mydomain.com/me/too/

So effectively the outside world does not even know that my extra links exist since they don't have any access to them.

Is this even possible?

Best Answer

I would do it like this

In your settings.py set the following

LOCAL_DEV = True

then in your urls.py

from django.conf import settings
if settings.LOCAL_DEV:
  urlpatterns = patterns('',
   #
   # all your other urls here for dev
   #
)