Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1068689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:19:09+00:00 2026-05-16T20:19:09+00:00

Summary: Say I have a project in Django called devsite which will be deployed

  • 0

Summary:

Say I have a project in Django called “devsite” which will be deployed first to a staging project (also called “devsite”) and finally to the live codebase (where the project is called “livesite”). During live deployments, I’d have to make manual changes to urls.py in order to import views from the right project. Which means urls.py in “devsite” would use something like:

from devsite import views

And urls.py for “livesite” would be changed to:

from livesite import views

My Solution:

The following seems to work (with limited testing so far). What I’ve done is create a variable in settings.py to get the project name from the directory, like so:

settings.py

# /settings.py
import os.path
PROJECT_NAME = os.path.basename(os.path.dirname(__file__))

And then use this to import the correct views in urls.py:

urls.py

# /urls.py
from django.conf import settings
website = __import__('%s' % settings.PROJECT_NAME, fromlist=['views'])
...
urlpatterns = patterns('',
    (r'^monty/$', website.views.monty),
)

My Question:

What I’d like to know is:

  1. Is this a good way of doing what I want to do, or is there a better way to code this?
  2. Or do I need to rethink my whole deployment workflow?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:19:10+00:00Added an answer on May 16, 2026 at 8:19 pm

    I would question why you have different projects for your live and dev sites. Why not keep all differences down to settings/configuration (as you do with PROJECT_NAME, for example) but keep your projects common? It seems you only increase any chances for error between dev and live the more you make each site diffferent.

    Other than that, I think what you’re doing is more or less fine. The other pattern I’ve seen is something like:

    try:
        from livesite import views
    except ImportError:
        from devsite import views
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that I have a widget that displays summary information about how many
Say I have this constructor: /// <summary> /// Example comment. /// </summary> public SftpConnection(string
Say I have an R list like this: > summary(data.list) Length Class Mode aug9104AP
Summary: I'm able to compile a RAD Studio 2009 project using MSBuild on a
I need to have a summary field in each page of the report and
I have a setup and deployment project that, on our build server, reports the
Quick summary: I have a Rails app that is a personal checklist / to-do
I have a C# dll project in Visual Studio 2008. In the project property
I will soon be beginning work on a project that (from the spec) reminds
Summary Hi All, OK, further into my adventures with custom controls... In summary, here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.