2

I am running Django with mod_python on a Red Hat Linux box in production. A little while ago, for a reason unknown to me, the admin stopped working, throwing a 500 error. The error is as follows:

ValueError at /admin/
Empty module name
Request Method: GET
Exception Type: ValueError
Exception Value: 
Empty module name
Exception Location: /usr/local/lib/python2.6/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.6.2

Has anyone encountered this before? I have absolutely no idea how to fix this problem.

Thank you for any help.

2
  • - Is the value error occurring in when you access /admin/ or a sub page of that? - Have you entered any new data into the admin app? (Maybe imported data from using a python script)? - What DB are you using? - Can you paste the entire traceback in djangosnippets or something similar Commented Nov 19, 2009 at 11:14
  • It occurs when I access /admin/. The admin panel has not had anything new added to it. The database is MySQL. I'll post the traceback. Commented Nov 20, 2009 at 2:42

1 Answer 1

5

I was just debugging this problem. The error arises when Django is attempting to set up the template context processors, and the root cause was a definition which should have been a tuple but was actually a string.

This is what I had in my config file:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth'
)

This is what I should have had:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
)

Without the trailing comma, Python treats the value of the variable as a string. Thus, Django code which looks like this:

for path in settings.TEMPLATE_CONTEXT_PROCESSORS:
    i = path.rfind('.')
    module,attr = path[:i],path[i+1:]

the first value of 'path' is 'd', not 'django.core.context_processors.auth'. This leads the value of 'i' to be -1 and thus the value of 'module' to be empty.

Make sure that all of the tuple-like things in your Django config are actually tuples, which means if they have a single value, they still need a trailing comma.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.