1👍
✅
You try to make cross importing. That is not allowed. Comment out the line 13 in "C:\Users\I812624\dev\mrp\src\item\models.py"
if you don’t need it.
or comment out the line 3 and 4 in:
"C:\Users\I812624\dev\mrp\src\product\models.py"
and do:
itemgroup = models.ForeignKey("item.ItemGroup", on_delete=models.PROTECT)
material = models.ForeignKey("item.Material", on_delete=models.PROTECT)
1👍
I’m kind of guessing here that you have circular imports going on. Something in item.models
is trying to import something from product.models
, which is trying to import something in item.models
…
The solution to that is avoid it entirely by allowing Django to handle the circular relationship instead of Python, like in the answer to this question.
So in your case, remove the import here and instead reference it like a string:
@with_author
class ItemGroup(models.Model):
# ...
subcategory = models.ForeignKey('product.SubCategory', on_delete=models.PROTECT)
# ...
- [Answered ]-Highcharts using Django-Chartit. Chart lines not displayed without window resize, or Inspect Element
- [Answered ]-Update / Save model date value directly from template?
- [Answered ]-Showing custom error messages in django model form with bootstrap
- [Answered ]-I have a list of objects and would like to return an attribute with another attribute
- [Answered ]-Range(1,1) is not processed by loop
Source:stackexchange.com