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

Ask A Question

Stats

  • Questions 251k
  • Answers 251k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer memcached is a really good choice for this since it's… May 13, 2026 at 9:33 am
  • Editorial Team
    Editorial Team added an answer The error you get is about source_reflection is an invalid… May 13, 2026 at 9:33 am
  • Editorial Team
    Editorial Team added an answer You need to keep the clip set when drawing your… May 13, 2026 at 9:33 am

Related Questions

I have an MVC view that contains a JQuery UI dialog that can be
I have two tables: Client(id,name,...) Purchase(id,item,date,client_id,...) They have their respective Model, with their validations.
If you have a controller method like so: @expose(json) def artists(self, action=view,artist_id=None): artists=session.query(model.Artist).all() return
So I have a class, specifically, this: class ProductVariantForm_PRE(ModelForm): class Meta: model = ProductVariant
I can't find a template for a linq to sql class in .net 2.0

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.