[tipfy] EnvironmentError DJANGO_SETTINGS_MODULE undefined, using django.core.validators

63 views
Skip to first unread message

Stephen Gornick

unread,
May 3, 2010, 1:34:38 PM5/3/10
to tipfy
I wish to continue using some django modules that AppEngine provides,
but now that I am using Tipfy and no longer importing webapp's
template module I get
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
undefined.

Any recommendations for a workaround?

He'res an example of what
from google.appengine.ext.webapp import template
from django.core.validators import email_re

email = 'te...@example.com'
is_valid = email_re.match(email)

--
You received this message because you are subscribed to the Google Groups "tipfy" group.
To post to this group, send email to ti...@googlegroups.com.
To unsubscribe from this group, send email to tipfy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tipfy?hl=en.

Rodrigo Moraes

unread,
May 4, 2010, 11:39:31 AM5/4/10
to tipfy
On May 3, 2:34 pm, Stephen Gornick wrote:
> I wish to continue using some django modules that AppEngine provides,
> but now that I am using Tipfy and no longer importing webapp's
> template module I get
>   EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> undefined.
>
> Any recommendations for a workaround?

Hi Stephen,
Did you solve this already? If not, set this somewhere before
importing django modules (config.py is fine):

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'config'

hope this helps.
-- rodrigo

Stephen Gornick

unread,
May 5, 2010, 4:08:24 AM5/5/10
to tipfy
Yup, that worked fine. Thanks!

Stephen Gornick

unread,
May 5, 2010, 4:10:29 PM5/5/10
to tipfy
This had the undesired side-effect where Django would set a 'TZ'
environment variable to "America/Chicago
", whereas under AppEngine TZ should be 'UTC'.

After reading the Django Doc,
http://docs.djangoproject.com/en/dev/topics/settings/#using-settings-without-setting-django-settings-module
so instead of assigning the DJANGO_SETTINGS_MODULE environment
variable, I instead manually configure Django settings:

# Configure Django settings manually to prevent TZ timezone
environment
# variable from getting assigned.
from django.conf import settings
settings.configure()


On May 5, 1:08 am, Stephen Gornick <sgorn...@gmail.com> wrote:
> Yup, that worked fine.  Thanks!
>

Reply all
Reply to author
Forward
0 new messages