Reputation:
I'm a newcomer to Python and Flask so I may be completely off with my app's organization. Here's what the directory structure looks like:
+ venv
+ bin
+ include
+ lib
+ myapp
- __init__.py
+ config
- __init__.py
- development.py
- production.py
+ templates
- layout.html
(more html files here and directories)
+ db
- development.db
- production.db
+ static
(all my css/js/etc)
+ views
- __init__.py
- main.py
+ models
- __init__.py
- game.py
Everything has worked so far, until I started working on models. I'm trying to import myapp.models.game
and for some reason it doesn't work. Instead it complains saying the myapp
module doesn't exist.
Why is this happening and what am I missing? Should I be organizing files in a different way?
Upvotes: 0
Views: 74
Reputation:
If you are already inside myapp, try importing just models.game. Also, be sure to make sure there really is an __init__.py
in each directory, as you will not be able to import the python module without it.
Upvotes: 1