I want to use Django's slugify
template function in my GAE script. When I use it in a HTML template, it works fine. But when trying the following import:
from django.template.defaultfilters import slugify
got this error:
File "/home/karlis/bin/google_appengine/lib/django_0_96/django/conf/__init__.py", line 53, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.
For a temporary solution I just copied the function from django files to a local file, but the question remains: is it possible to use template functions like this and what should I put in the settings file?
This might work (without actually creating a settings module):
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.template.defaultfilters import slugify
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.