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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:33:14+00:00 2026-05-17T15:33:14+00:00

I am trying to get the best possible set up for developing my django

  • 0

I am trying to get the best possible set up for developing my django project from the start and I’m having trouble getting everything to play nicely in the directory structure. I have set up virtualenv’s (env in this example) so that I can deploy a clean empty python environment for every django project.

The basic structure is as follows:

/env/
    /bin
    /db         <--- Django DB
    /downloads
    /lib
    /static     <--- Where css/imgs/js etc is served from
    /project/   <--- Django root
            /__init__.py
            /settings.py
            /manage.py
            /appsfolder/
                 /appname/
                       /__init__.py
                       /models/
                              /__init__.py
                              /somemodel.py
                       /urls/
                             /__init__.py
                             /someurl.py
                       /views/
                             /__init__.py
                             /someview.py

This is the basic layout; I want each project to have a directory for applications, and in each application have a separate folder for models, view and urls.

The problem I am having is with the python path and how the modules are handled.

Within an application, I don’t want to have to refer to the project when importing models i.e I should be using :

import appname.models.modelname

not:

import projectname.models.modelname

to help reusablility

In the models directory, I have the following init.py

from model1 import ModelName1
from model2 import ModelName2
from model3 import ModelName3

__all__ = ['ModelName1', 'ModelName2', 'ModelName3']

But when I try to use a separate url file (in /appname/urls/urlfile.py) and import the models like the following:

from appname.models.somemodel import ModelName

I get a “module not found” error.

while:

from appsfolder.appname.models.somemodel import ModelName

works ok

I presume this is because the application is not directly on the python path, instead it is in a subfolder called appsfolder, but I’m not sure how to go about fixing this, while keeping everything reuseable and relative.

I know one solution is to put all apps directly on the python path under site-packages, but I don’t really like this idea, as I think that the applications should be in the project if you are using virtualenv’s

  • 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-17T15:33:15+00:00Added an answer on May 17, 2026 at 3:33 pm

    You can put the following in your settings.py to add your appsfolder to your PYTHONPATH:

    import os
    import sys
    
    PROJECT_ROOT = os.path.dirname(__file__)
    sys.path.insert(0, os.path.join(PROJECT_ROOT, 'appsfolder'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView where I am trying to get the best possible scrolling
I am trying my upmost best to get my head around regex, however not
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I'm trying to identify what would be the best selling point for a set
So i am trying get 2 div-containers which both should contain centered text (Both
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using
Trying to get a wildcard search to pick up on any text in org_name
trying to get same string on tooltip as is in the Text e.g. Text=<%#

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.