I have gotten myself into a problem here and I can't see why. Can anyone help debug this?
I am getting the following error anytime I try to go to any URL:
ViewDoesNotExist at /admin/
Could not import g001.api.data. Parent module g001.api does not exist.
Request Method: GET
Request URL: http://jfmario.pythonanywhere.com/admin/
Django Version: 1.6.6
Exception Type: ViewDoesNotExist
Exception Value:
Could not import g001.api.data. Parent module g001.api does not exist.
Exception Location: /usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py in get_callable, line 104
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.4.3
Python Path:
['/var/www',
'.',
'',
'/home/jfmario/.local/lib/python3.4/site-packages',
'/var/www',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages',
'/home/jfmario/site01']
g001 does exist, as do other apps that work fine ( when I comment g001 out of urls.py ). The file structure is as follows:
site01/
manage.py
site01/
urls.py
settings.py
the other main stuff
pavachlang/ ( a working app )
__init__.py
api.py
models.py
admin.py
other files
g001/ ( does not work )
__init__.py
api.py
models.py
admin.py
other files
That's the general structure. I have views.py in both as well. I have template based responses there and JSON based responses in api.py. I've used django for small things several times, and the other api.py was working before, so I don't think its an issue that I'm referencing a view function that is not in views.py.
From site01/site01/settings.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'g001',
'pavachlang',
# and a few other apps
)
and from site01/site01/urls.py:
g001_API = patterns ( 'g001.api',
url ( r'^data/(?P<slug>[0-9A-Za-z_-])$', 'data' )
)
and then in the urlpatterns
# other working stuff
# the whole thing works if I exclude this next line by comment
( r'^g001/', include ( g001_API ) ),
( r'^pavachlang/api/', include ( pavachlang_API ) ),
# other working stuff and then the admin urls
There are no major differences between the pavachlang/ and g001 folders. Both have init.py. Interestingly, running syncdb works, and I've put data into the MySQL database for the g001.models. I did the models first. admin.site.register was not working, so the tables existing in MySQL but would not show in admin. Then I made a simple view in api.py that echos out some json from the table and when I tried to reference it that is when I got the error.
The only clue I have that something is wrong is that pavachlang/ and the other working apps have a pycache directory magically in them and g001/ does not.
Is there a simple misspelling I am not seeign, and if not how can I narrow in on the problem?
PS, using manage.py shell, I can import g001 and its models and its view functions just fine ( as well as from the regular python shell ).
PS2: init.py does have 2 underscores, but markdown is removing them.
PS3: Also, from the shell I can import g001, get its models, play with objects.all () and manipulate adn save them.
PS4: No virtualenv, Django 1.6 with Python3.4.