Reputation:
I have a file structure like so:
app.yaml
something/
__init__.py
models.py
test.py
I have URL set up to run tests.py
in app.yaml
:
...
- url: /test
script: something/test.py
test.py
imports models.py
When I try to navigate to http://myapp.appspot.com/test/
I get the following error:
Error: Server Error The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the > query that caused it
And, when I check the logs on the dashboard I see the following error occurred:
<type 'exceptions.ImportError'>: No module named models
How do I import the file properly?
Cheers,
Pete
Upvotes: 1
Views: 890
Reputation: 7347
inside test.py you can write at the top something like:
from something.models import *
This will import your models. For corrective code though - the wildcard '*' is not great and you explicitly import the models your using:
from something.models import ModelName, OtherModel
and so on.
Upvotes: 1
Reputation: 74054
Try to import models
like this:
import something.models as models
Upvotes: 0