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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:10:47+00:00 2026-05-22T16:10:47+00:00

I am just getting this django app (also an inexperienced python user) running and

  • 0

I am just getting this django app (also an inexperienced python user) running and wanted to be able to access the models.

I have the following:

import sys, os
sys.path.append('/Users/jx/dev/arc/django/second/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.db import models
from testproject.models import Location
loc=Location.objects.get(name='Joes')

print loc.name

but get the following error:

Traceback (most recent call last):
  File "zz.py", line 6, in <module>
    from testproject.models import Location
ImportError: No module named testproject.models

Is there a way I can determine whether it is loading the settings.py correctly? Or is there an obvious syntax issue? Should the PYTHONPATH reflect the locations for the models (it currently doesn’t if print os.environ)?

thx

  • 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-22T16:10:48+00:00Added an answer on May 22, 2026 at 4:10 pm
    1. Make sure you have added the folder containing testproject folder to sys.path.
      For example if you have the following structure /foo/bar/testproject/models.py then you should add /foo/bar to sys.path
    2. Make sure the testproject folder has a __init__.py file in it (which can be empty).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with django and I'd like to extend the basic django.contrib.auth.models.User class
I'm trying to implement django-filebrowser into my latest app. I have grappelli installed also.
I have a Django app running django-piston for the first time. I've got a
This is for Django 1.2.5 and Python 2.7 on Wamp Server running apache version
I just started getting this error today, seemingly out of nowhere. Any one see
I'm getting this error after trying to appendChild to an element that was just
I am just getting started with expression trees so I hope this makes sense.
I am just getting started with IoC containers so apologies if this is a
I just installed an application on a win2003 server and I'm getting this error:
I just wrote a new web part and now I am getting this error

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.