I've go some python modules which automatically connect to the database then they are loaded beacuse they have an __init__.py with
from django.core.management import setup_environ
import passion.settings
def loadSettings():
s = setup_environ(passion.settings)
print s
# this should only be run from the workbox not on the server
loadSettings()
This works fine even when it can't connect.
But later if I do:
from passion.cg.models import *
users = User.objects.filter( username='julian')
print users
then I get
# OperationalError: (1044, "Access denied for user ''@'localhost' to database 'djangostack'")
# - [line 3]
So I need a way to test the connection before trying to use the django models.
I can just check for exceptions, but is there a better way?
Julian
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment