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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:52:11+00:00 2026-05-13T05:52:11+00:00

How can you have model declarations at two different directories in Django? I have

  • 0

How can you have model declarations at two different directories in Django?

I have the model at the directory Code which contains “init.py”, “models.py” and “admin.py”.
It is working properly alone.

I want to have the directory History which has the model of the revisions of the given questions. I have the similar files in the directory.

I need to tell Django to use the model at the directory “History” somehow, since I have a ManyToMany relation in the table Questions to the other directory.

I get the following import error

ImportError at /

cannot import name history

Request Method:     GET
Request URL:    http://127.0.0.1:8000/
Exception Type:     ImportError
Exception Value:    

cannot import name history

Exception Location:     /home/noa/build/CML/../CML/codes/models.py in <module>, line 2
Python Executable:  /usr/bin/python
Python Version:     2.6.2
Python Path:    ['/home/noa/build/CML', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/var/lib/python-support/python2.6/pyinotify', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '/usr/local/lib/python2.6/dist-packages']
Server time:    Fri, 11 Dec 2009 15:46:30 -0600
  • 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-13T05:52:11+00:00Added an answer on May 13, 2026 at 5:52 am

    Since it sounds like both of your directories are Django apps, and assuming you’ve put both of them in your INSTALLED_APPS list in settings.py you can refer to them using a string without having to import:

    # in code/models.py
    
    class Questions(models.Model):
        histories = models.ManyToManyField('history.MyHistoryModel')
    

    Note that the path is case sensitive… so if you app is truly called ‘History’ you will need to reference it using ‘History.MyHistoryModel’.

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

Sidebar

Related Questions

I have Boys and Toys. Two django models. Toys can be owned by more
Say that I have two models- Users and Accounts. Each account can have at
How can I achieve the following? I have two models (blogs and readers) and
I'm used to the Java model where you can have one public class per
Can I have a custom service providing the storage of the models I use
You can have different naming convention for class members, static objects, global objects, and
I have a class Person which can have several Homes, each one with one
I have a View that can vary significantly, depending on the 'mode' a particular
Routines can have parameters, that's no news. You can define as many parameters as
I have a program that can have a lot of parameters (we have over

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.