Django ImportError for valid import -


i think best explained little code. aware weird relationships between data hack inlines working many-to-many relationships.

the app "data" has following models.py:

from crawler.models import crawljoin  class website(models.model):     hack = models.foreignkey(crawljoin, null=true, blank=true, editable=false) 

the app "crawler" has following models.py:

from data.models import website  class crawljoin(models.model):     pass  class crawl(models.model):     websites = models.manytomanyfield(crawljoin, through='website') 

if try migrate either crawler or data, following error:

importerror: cannot import name 'crawljoin' 

do know how can resolve issue? far can tell, should not getting error...

thank you.

you have circular import because both models modules trying import each other. can break circular import removing import , using string in foreign key:

hack = models.foreignkey('crawler.crawljoin', null=true, blank=true, editable=false) 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -