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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:25:59+00:00 2026-05-26T00:25:59+00:00

I got an error I don’t understand ! cannot import name Item In my

  • 0

I got an error I don’t understand !

cannot import name Item

In my model, I have items. These items are required for actions. But some of these items have an effect on actions :

items

from django.db import models
from effects.models import Effect

class Type(models.Model):
    name = models.CharField(max_length=200)

    def __unicode__(self):
         return self.name

class Item(models.Model):
    name = models.CharField(max_length=200)
    description = models.CharField(max_length=200)
    type = models.ForeignKey(Type)
    quality = models.IntegerField()
    effects = models.ManyToManyField(Effect,through='ItemEffect',blank=True)
    item_requirement = models.ManyToManyField('self',through='ItemCraft',symmetrical=False,blank=True)
points = models.IntegerField()

    def __unicode__(self):
        return self.name

class Food(Item):
    ap = models.IntegerField()

class Tool(Item):
    durability = models.IntegerField()

[....]

class ItemEffect(models.Model):
    item = models.ForeignKey(Item)
    effect = models.ForeignKey(Effect)

def __unicode__(self):
    return self.item.name+':'+str.lower(self.effect.name)

class Meta:
    verbose_name_plural = 'items effects'

class ItemCraft(models.Model):
    item = models.ForeignKey(Item,related_name='%(class)s_item_crafted')
    item_requirement = models.ForeignKey(Item,related_name='%(class)s_item_required')
    number = models.IntegerField()

    def __unicode__(self):
        return self.item.name+' requires '+str.lower(self.item.name)+'('+self.number+')'

    class Meta:
        verbose_name_plural = 'items crafts'

actions

from django.db import models
from items.models import Item

class Action(models.Model):
    name = models.CharField(max_length=200)
    description = models.CharField(max_length=200)
    pa = models.IntegerField()

    def __unicode__(self):
        return self.name

class CraftAction(Action):
    item = models.ForeignKey(Item)

    def __unicode__(self):
        return self.item.name+'\'s craft'

    class Meta:
        verbose_name_plural = 'crafts actions'

effects

from django.db import models
from actions.models import Action

class Effect(models.Model):
    action = models.ForeignKey

class ApEffect(Effect):
    ap = models.IntegerField()
  • 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-26T00:26:00+00:00Added an answer on May 26, 2026 at 12:26 am

    There is a circular import in your code, that’s why the Item can’t be imported in action.

    You can solve the problem by removing the import of a class in one of your files, and replacing it with a string containing the name of the class, as explained in the documentation. For example :

    effects = models.ManyToManyField('effects.Effect',through='ItemEffect',blank=True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while using document cookie <script typ=text/javascript> document.domain=example.com; </script> I got an error.i don't know
I don't understand why I get the error message when I run JSLint with
i currently trying to get my model loader to work and got a error
I start learning LINQ these days. I got an error when I try to
Griffon JMX Plugin 0.3 don't work. anyone use this version 1.got error: no lib
Anyone can help? Don't know why got error? ??? Assignment has more non-singleton rhs
I got an error in my Magento 1.5.1 installation, that I don't know how
i got an error CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an
GOT error for the following query in MYSQL(version5.1) SELECT year,month,sum(fact_1),sum(fact_2),sum(fact_3),sum(fact_4) from( select year,month,fact_1,fact_2,0 as
I got error Access Violation when the following code is execute : void NoAction()

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.