开发者

Django path error - No module named models

I have an import error in a Django app, I guess it's pretty simple but I can't figure it out…

It's a simple notepad app, called «notes» with 2 models, «note» & «category». To clean things up, I wanted to seperate each models views & urls, so here is what I get:

/notes

    admin.py

    forms.py

    models.py

    /urls

        category.py

        note.py

  &开发者_运维问答nbsp; /views

        category.py

        note.py

The problem is that my views don't find the models, here is the Traceback - http://dpaste.com/hold/539425/ and parts of the code: http://dpaste.com/hold/539416/

I didn't mention the _init_.py files in the above snippet, but I double-checked all of them…


Your code pastie says from notes.models import Category, Note but your traceback says from models import Category, Note. It's hard to tell if those are the same line because you're only pasting snippets. Still, it should be 'from notes.models import foo' always.

Are you sure you're always referencing the notes app in your models import?

UPDATE:

If you're using the correct from foo.models import bar syntax, then my next thoughts are that you've possibly got a circular dependency that's stopping Python importing things from the models file.

But the traceback implies the notes/models.py can't be found. So... when you say you double-checked the init.py files, that doesn't mean they're right. :p There should be one in notes/ and also in notes/urls/ -- they don't have to contain anything.


It should be

from notes.models import Category, Note
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜