Hello All,

I am getting the following error on Django 1.1:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
    result = object(req)

  File "django/core/handlers/modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "django/core/handlers/modpython.py", line 201, in __call__
    response = self.get_response(request)

  File "django/core/handlers/base.py", line 73, in get_response
    response = middleware_method(request)

  File "project/order/middleware.py", line 15, in process_request
    request.order = get_order(request)

  File "project/order/middleware.py", line 10, in get_order
    return Order()

  File "django/db/models/base.py", line 307, in __init__
    val = field.get_default()

  File "django/db/models/fields/related.py", line 728, in get_default
    if isinstance(field_default, self.rel.to):

TypeError: isinstance() arg 2 must be a class, type, or tuple of
classes and types



Basically I have two apps:

in order/models.py
class Order(models.Model):
    account = models.ForeignKey('account.Account')

in account/models.py:
class Account(models.Mode):
     name = models.CharField(max_length=100)

The TypeError is being thrown because self.rel.to is
"account.Account". At the point of the middleware processing, account/
models.py hasn't been imported yet, therefore the Account model has
not been registered, so self.rel.to has not yet been resolved to the
actual Account model.

This error does not happen in the shell or in a runserver, probably
because I know at least shell calls get_models() which forces all
models to be registered.

This seems related to http://code.djangoproject.com/ticket/1796.

Am I the only one who has ran into this problem? I can think of
several workarounds, but is there an actual solution to this problem,
or is this a bug in django? Shouldn't all models be registered when
mod_python starts up?

Thanks,
Collin Anderson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to