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

  • SEARCH
  • Home
  • 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 6838995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:39:55+00:00 2026-05-26T23:39:55+00:00

I have a django app runs on Apache with mod_wsgi and my wsgi file

  • 0

I have a django app runs on Apache with mod_wsgi and my wsgi file looks like :

import os
import sys

sys.path.append('/home/UNAME/DP/')
sys.path.append('/home/UNAME/DP/pr1/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I have also created another app as pr1_developer and its wsgi is :

import os
import sys

sys.path.append('/home/UNAME/DP/')
sys.path.append('/home/UNAME/DP/pr1_developer/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

However, in my ‘views’, ‘urls’, ‘models’,’forms’ and other python files import necessary classes as

from pr1.main.models import Country,City, Months
from pr1.employer.models import EmployerStatus
...

However, when I try to run pr1_developer application I need to change the headers like from pr1.main.. to pr1_developer.main.. in every file.Otherwise pr1_developer runs the modules from pr1.

As you except, I don’t want to create two different files for each project but how can I overcome such difficulty ?

One approach may writing from main... instead of from pr1.main... however, I am not sure if it is a good way to do this.

I am appreciated for any suggestion.

  • 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-26T23:39:55+00:00Added an answer on May 26, 2026 at 11:39 pm

    tldr; Might be better to use virtualenv.

    I am but an egg but I think the gurus will discourage from messing around with sys.path. My excursions with it have made my code less portable among hosts and projects, introduced weird breakage points (for instance, sometimes equality tests fail b/c when one object has class ‘pr1.main.models’ and another ‘pr1.test.main.models’) and created dependencies that I’ve later had trouble remembering. These efforts were generally attacks on some dimly-understood problem of project or workflow management. The sys.path solutions weren’t worth the technical debt they introduced.

    Using sys.path usually means some structural problem of a sort that, as a newbie, I haven’t dealt with often and then didn’t understand very well. This stuff always comes up when I’m in a hurry to get something else done, but I’m trying to remember that getting this sort of thing right makes everything else easier down the road.

    A tool like virtualenv might serve you better. You’d have a pr1 environment, with the initial code, and a pr1_dev environment with different code (but the same module names). You could have one terminal window running the one and another running the other. When something in _dev is ready for primetime it can be moved in without changing its imports or namespace references. Of course, you’ll have to spend time learning another tool rather than pushing forward whatever it is you’re working on.

    See http://pypi.python.org/pypi/virtualenv for virtualenv. Doug Hellman has also written mkvirtualenv (http://doughellmann.com/2008/05/01/virtualenvwrapper.html), a bash level script for managing the environments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django app running on Apache with wsgi module. After few hours
I have configured my Django app to run under Apache+FastCGI on Linux (Ubuntu, if
I have a python/django application that runs on the google app engine. My views.py
I have python/django app on Heroku (Cedar stack) and would like to make it
I have a django app and I would like to have an experience on
I have a simple class in a Django app called project from django.test import
The app runs fine using django internal server however when I use apache +
App A is written in Python 2.5 with Django and runs on an Apache
I have a Django app that lets a user upload a file and does
I have a django app that has a horizontal nav. The horizontal nav looks

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.