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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:03+00:00 2026-05-20T01:23:03+00:00

I have a Django model where I’m importing a number of items: from django.db

  • 0

I have a Django model where I’m importing a number of items:

from django.db import models
from mcif.models.import_profile import ImportProfile
from mcif.models.import_file import ImportFile
from mcif.models.import_bundle import ImportBundle
from mcif.models.customer import Customer
#from mcif.models.account_import import AccountImport
from mcif.models.csv_row import CSVRow
import csv, cStringIO

It works fine, but when I uncomment that line that’s commented, I get this:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/pymodules/python2.6/django/core/management/commands/shell.py", line 18, in handle_noargs
    loaded_models = get_models()
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 167, in get_models
    self._populate()
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 64, in _populate
    self.load_app(app_name)
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/jason/projects/mcifdjango/mcif/models/__init__.py", line 5, in <module>
    from mcif.models.account_import import AccountImport
  File "/home/jason/projects/mcifdjango/mcif/models/account_import.py", line 2, in <module>
    from mcif.models.generic_import import GenericImport
  File "/home/jason/projects/mcifdjango/mcif/models/generic_import.py", line 6, in <module>
    from mcif.models.account_import import AccountImport
ImportError: cannot import name AccountImport

Why doesn’t Django like this one particular file?

(I can load AccountImport by itself on the console just fine.)

Also, here’s AccountImport if it helps to see it:

from django.db import models
from mcif.models.generic_import import GenericImport

class AccountImport(models.Model):

    id = models.BigIntegerField(primary_key=True)
    generic_import = models.ForeignKey(GenericImport)
    is_entirely_international = models.IntegerField()
    is_queued = models.IntegerField()
    created_at = models.DateTimeField()
    updated_at = models.DateTimeField()

    class Meta:
        db_table = u'account_import'
        app_name = 'mcif'

And GenericImport:

from django.db import models
from mcif.models.import_profile import ImportProfile
from mcif.models.import_file import ImportFile
from mcif.models.import_bundle import ImportBundle
from mcif.models.customer import Customer
from mcif.models.csv_row import CSVRow
import csv, cStringIO

class GenericImport(models.Model):

    class Meta:
        db_table = u'generic_import'
        app_name = 'mcif'

    id = models.BigIntegerField(primary_key=True)
    import_profile = models.ForeignKey(ImportProfile)
    import_file = models.ForeignKey(ImportFile)
    notes = models.TextField()
    start_time = models.DateTimeField()
    end_time = models.DateTimeField()
    active = models.IntegerField()
    created_at = models.DateTimeField()
    updated_at = models.DateTimeField()
    unsavable_rows = models.TextField()
    import_bundle = models.ForeignKey(ImportBundle)
    is_queued = models.IntegerField()

    @classmethod
    def last(cls):
        all = GenericImport.objects.all()
        return all[len(all) - 1]

    def process(self):
        for line in self.import_file.file.split("\n")[:30]:
            f = cStringIO.StringIO(line)
            row = CSVRow()
            row.array = next(csv.reader(f))
            row.generic_import = self
            row.process()
            f.close()

    def specific_import(self):
        for model_name in ['TransactionImport', 'AccountImport']:
            specific_imports = eval(model_name + '.objects.filter(generic_import__pk=5)')
            if len(specific_imports) > 0:
                return specific_imports[0]
        return False
  • 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-20T01:23:03+00:00Added an answer on May 20, 2026 at 1:23 am

    You have a circular import – mcif.models.generic_import and mcif.models.account_import are trying to import each other.

    Remember that Python is not Java, and is quite happy to have multiple classes in a single file, especially if they’re closely related like these two seem to be. Put them both in a single mcif.models file.

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

Sidebar

Related Questions

I have a Django model and from. class Settings(models.Model): field_1 = models.BooleanField() field_2 =
I have this Django model (from Django CMS): class Placeholder(models.Model): slot = models.CharField(_(slot), max_length=50,
Say I have django model that looks something like this: class Order(models.Model): number =
I have this Django model: class Lecture(models.Model): lecture_number = models.CharField(_('lecture number'), max_length=20) title =
I have django models such as this class District(models.Model): name = models.CharField(max_length=30,unique=True) number =
So I can create Django model like this: from django.db import models class Something(models.Model):
If I have a Django model with a FileField e.g., class Probe(models.Model): name =
I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I have Django model that looks like this: class Categories(models.Model): Model for storing the
I have a django model with a DateTimeField. class Point(models.Model): somedata = models.CharField(max_length=256) time

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.