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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:29:37+00:00 2026-06-15T10:29:37+00:00

In my django application I have an app called projects and and app called

  • 0

In my django application I have an app called projects and and app called utils. I also have a module inside projects called utils to hold helper functions for just projects.

So my file structure would look something like this

...
projects/
    utils/
        globals.py
    views.py
utils/
    tests.py
...

I ran into a problem when I tried to import something from utils (outer one) and django thought I was importing from projects.utils. So this gave me an error

# inside projects.views.py
from utils.tests import foo

Since I don’t have tests.py in projects.utils, the import gave me an error. Of course, I knew that and was trying to reference the outer utils.

Is there a way to reference both the outer utils and the projects.utils clearly in django or should I just change the name of projects.utils to something else?

  • 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-06-15T10:29:38+00:00Added an answer on June 15, 2026 at 10:29 am

    By default, an import utils call in modules directly contained in the projects package will try a relative import first and pick up projects.utils.

    The easiest method would be to turn on absolute imports via the following pragma at the top of your module:

    from __future__ import absolute_import
    

    This turns off this implicit relative import behaviour (which also makes it match Python 3), so import utils will always pick the top level module. Note that the pragma will only affect imports within the file it occurs: if you want the behaviour in multiple modules, you will need to include the pragma in each file.

    You can still perform relative imports in this mode, but you will have to be explicit:

    from . import utils
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django application, with a module called app Now this module has
HI I have a django application running on app engine and I want to
I have a reviews/ratings web application, a la Digg. My django app content has
I have a python/django application that runs on the google app engine. My views.py
I have a django app on my local computer. I can access the application
I have a Django app called publisher, it connects to various signals in my
I have a django app runs on Apache with mod_wsgi and my wsgi file
I have created a django application. Using this app users can be created or
I have a App Engine/Python/Django application which has grown and been modified over the
Scenario: I have an app in my Django application that I have never put

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.