PythonAnywhere->ImportError raised loading nrpccms.newsroom.templatetags.blog_extras: No module named settings

StackOverflow https://stackoverflow.com/questions/19461543

Question

I'm trying to deploy my very first app in PythonAnywhere (or at AnywhereAnywhere for that matter). I'm currently getting:

TemplateSyntaxError: 'blog_extras' is not a valid tag library: ImportError raised loading nrpccms.newsroom.templatetags.blog_extras: No module named settings

full error log
see error live

The app newsroom is the very first one in INSTALLED_APPS:

#! python
# ...
INSTALLED_APPS = (
    "nrpccms.newsroom",
    "django.contrib.admin",
# ...

blog_extras.py is at MY_PROJECT/MY_APP/templatetags and there is a __init__.py at MY_PROJECT/mY_APP.

Can you pinpoint my mistakes?

Was it helpful?

Solution 2

Fixed: I had to add my projects folder to sys.path in my wsgi script. This is my new wsgi script:

activate_this = '/home/nimbiotics/.virtualenvs/nrpccms/bin/activate_this.py' execfile(activate_this, dict(file=activate_this))

import os import sys

path = '/home/nimbiotics/projects' if path not in sys.path: sys.path.append(path)

##################################################### nrpccms_path = '/home/nimbiotics/projects/nrpccms' if nrpccms_path not

in sys.path: sys.path.append(nrpccms_path)

#

os.environ['DJANGO_SETTINGS_MODULE'] = 'nrpccms.settings'

import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

OTHER TIPS

blog_extras.py is in the wrong folder

my_project/    
    my_app/
        __init__.py
        models.py
        views.py
        templatetags/
            __init__.py
            blog_extras.py

blog_extras.py should exist in templatetags directory, at the same level as models.py, views.py, etc. If this doesn’t already exist, create it - don’t forget the init.py file to ensure the directory is treated as a Python package.

Official documentation on Custom Template Tags

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top