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 3424958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:32:12+00:00 2026-05-18T06:32:12+00:00

I installed wsgi (mod_wsgi), and could run the simple application by calling http://localhost/myapp .

  • 0

I installed wsgi (mod_wsgi), and could run the simple application by calling http://localhost/myapp.

WSGIScriptAlias /myapp /Library/WebServer/Documents/wsgi/scripts/myapp.wsgi
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World! WSGI working perfectly!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

How can I run django example?

I found this example that has the simple example.

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'my.settings' # ???

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
mysite/
    __init__.py
    manage.py
    settings.py
    urls.py

Django generated the three python files, and I see a settings.py that has setup info.
The project is in ‘/ABC/DEF/mysite’ directory.

I modified the code as follows, and named it myapp.wsgi.

import os
import sys

sys.path.append('/ABC/DEF/mysite') 
sys.path.append('/ABC/DEF')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

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

Even though I could run the original django example from the tutorial that uses “python manage.py runserver 8080”, I got an error running the modified example with mod_wsgi.

The apache2/log file has the following.

[Wed Nov 24 09:02:41 2010] [error] [client 127.0.0.1] ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings

As far as I know, the directory/project name is mysite, and it has the settings.py. And the directory is in the sys.path. So, I don’t know why mysite.settings is not found.

What’s wrong with my myapp.wsgi?

SOLVED

The following code works fine.
And the other thing that I modified was the django project should not be in my home directory, when I moved the project to www doc directory, everything works fine.

import os
import sys

mysite = 'SOMEWEHRE/django'
if mysite not in sys.path:sys.path.insert(0,mysite)
mysite = 'SOMEWEHRE/scripts'
if mysite not in sys.path:sys.path.insert(0,mysite)

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

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
  • 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-18T06:32:13+00:00Added an answer on May 18, 2026 at 6:32 am

    What you need to do is add either the project directory or the directory the project is in to sys.path, and then point the settings to mysite.settings if you’ve done the latter.

    EDIT:

    “Django settings”

    EDIT 2:

    How to set the Django settings module

    EDIT 3:

    The settings module should be the module, not the filename. And if it’s 'settings' then you don’t need to set it.

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

Sidebar

Related Questions

Installed a fresh Delphi xe2. Open a new project (vcl forms application). opened the
I receive this error when I try to run Apache 2.2 with mod_wsgi, I
I'm writing a bare bones Python wsgi application and am getting stumped by module
I have a Pyramid app that I've been developing and viewing locally through http://localhost:6543
In a flask application I wrote, I make use of an external library which
I have installed Python 2.7 and mod_wsgi. I've added LoadModule wsgi_module modules/mod_wsgi.so to the
I'm very sorry for such a simple question-- I'm new at WSGI development, and
I'm trying to run Django 1.3.1 on apache 2.6.6, using mod_wsgi, CentOS 6. I
I have trac installed and running great using apache2 and mod_wsgi. However when ever
I have installed Django, Apache2 and even mod_wsgi. With a project, I have Django

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.