1

I should note that there is an __init __.py file in the application directory.

I believe I know the source of the error. It seems to lie in the application's views.py file.

from tbg.myapp.models import Document
from tbg.myapp.forms import DocumentForm

Showing you as little as possible, this is a part of what I imported. I observe that if I remove the tbg, for example, the error will alter to no module named myapp.

How do I fix this?

3
  • Please have a look into your settings.py file, have you included the app in the INSTALLED_APPS, with a proper name. Commented Jun 10, 2014 at 11:04
  • Yes, the app name is in there. I have it as simply "myapp". If I change it to "tbg.myapp", tbg is the project name, then the server immediately crashes, saying "no module named myapp" again. Commented Jun 10, 2014 at 11:06
  • Can you please let me know the directory structure of your application. Commented Jun 10, 2014 at 11:08

1 Answer 1

2

Assuming tbg is the name of your project, your project's directory structure should be something like below:

tbg/  # your project's main folder
 |-- tbg/  # inner tbg folder which contains settings, urls, etc.
 |      __init__.py, settings.py, etc.
 |-- myapp/
        models.py, etc.

So when you are writing from tbg.myapp.models import Document, you are referring to the tbg folder inside your project's main folder. As this tbg folder doesn't have myapp folder, you are getting an error.

To fix this, write from myapp.models import Document.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, the error was elsewhere. It was in my urls.py, but the reason is the same, so I will mark your answer as correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.