Import a custom py file into views.py

7 views
Skip to first unread message

Alessandro Candini

unread,
Feb 9, 2012, 10:21:29 AM2/9/12
to django...@googlegroups.com
Hi list.
In my project named STO I have the 'jsonopenlayers' app with the
following structure:

STO
├── __init__.py
├── jsonopenlayers
│ ├── ingestion
│ │ └── ingestShp.py
│ ├── __init__.py
│ ├── models.py
│ └── views.py
├── manage.py
└── settings.py

What I would like to do is to import the functions written inside
ingestShp.py into my views.py.

I've tried in several ways, for example with

from jsonopenlayers.ingestion.ingestShp import *

inside the views.py file, but I get the error

Could not import jsonopenlayers.views. Error was: No module named
ingestion.ingestShp

How can I import this file?

Thanks in advance

Daniel Roseman

unread,
Feb 9, 2012, 10:33:58 AM2/9/12
to django...@googlegroups.com
Your structure should give you a clue. What file exists in every directory, except for "ingestion"? Hint: it begins with "_". You need it in your "ingestion" directory too.
--
DR.

Adnan Sadzak

unread,
Feb 9, 2012, 10:43:13 AM2/9/12
to django...@googlegroups.com
How python treat some folder as module? You need to add __init__.py into it.
Reply all
Reply to author
Forward
0 new messages