ValueError: Empty module name

1,323 views
Skip to first unread message

cory

unread,
Feb 16, 2007, 3:27:24 PM2/16/07
to Django users
Hello all,

I keep getting a very strange error in my latest Django project. It
repeatedly sends back a ValueError saying 'Empty module name', but in
the debug output all of the settings from the settings files are
displayed correctly and the settings file that's listed is the correct
one.

The only thing I can think of is, something isn't right with how
mod_python is accessing the project. There are two locations in my
httpd.conf file for this project:

<Location "/">
SetHandler python-program
PythonInterpreter main_site
PythonHandler django.core.handlers.modpython
PythonPath "['/home/cory/projects'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE main_project.settings
PythonDebug On
PythonAutoReload On
</Location>

<Location "/demo/">
SetHandler python-program
PythonInterpreter demo_site
PythonHandler django.core.handlers.modpython
PythonPath "['/home/cory/projects'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE main_project.demo.settings
PythonDebug On
PythonAutoReload On
</Location>

Because this project entails allowing people to set up their own site
running the Django code of the project, then hosting that site, it's
imperative that the 'demo' be able to separate from the main project.
I've also tried separating them by using VirtualHosts, and have gotten
the same result.

Does anyone have any suggestions?

Thanks.

cory

Malcolm Tredinnick

unread,
Feb 16, 2007, 8:10:57 PM2/16/07
to django...@googlegroups.com
On Fri, 2007-02-16 at 12:27 -0800, cory wrote:
> Hello all,
>
> I keep getting a very strange error in my latest Django project. It
> repeatedly sends back a ValueError saying 'Empty module name', but in
> the debug output all of the settings from the settings files are
> displayed correctly and the settings file that's listed is the correct
> one.

You may need to provide a little more information for this: where is the
error coming from? Can you work out what sort of "module name" it is
expecting?

Your problem may be simple to fix, though...

> The only thing I can think of is, something isn't right with how
> mod_python is accessing the project. There are two locations in my
> httpd.conf file for this project:
>
> <Location "/">

[...]
> </Location>
>
> <Location "/demo/">
[...]
> </Location>

"Location" directives in Apache are processed in the order they appear
in the file. So your first block will catch *all* URLS and the second
block will never be applied. In this case, you can probably work around
that by just reversing the order of the Location blocks. In other, more
complicated cases, you can use LocationMatch (instead of Location) to
exclude certain match patterns.

Regards,
Malcolm


cory

unread,
Feb 17, 2007, 3:32:20 PM2/17/07
to Django users
Ah-ha! I think I've found the issue.

The problem was coming from the template context loader I was using.
Or rather, how that was set in the settings.py file. I only had one
template context loader set, and forgot to include a trailing comma so
that it could be processed as a tuple instead of a string. Once I
added that, everything works as it should. Just one of those little
gotchas that you have to look out for.

On Feb 16, 7:10 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Reply all
Reply to author
Forward
0 new messages