sijeesh / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

app-engine-django AuthenticationMiddleware throwing KindError #185

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add 'appengine_django.auth.middleware.AuthenticationMiddleware' to 
MIDDLEWARE_CLASSES

What is the expected output? What do you see instead?
I would expect that it would add a user to my request

instead it throwing a 500:
<class 'google.appengine.ext.db.KindError'>: reference_class must be Model or 
_SELF_REFERENCE
Traceback (most recent call last):
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/main.py", line 59, in <module>
    main()
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/main.py", line 56, in main
    util.run_wsgi_app(application)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 97, in run_wsgi_app
    run_bare_wsgi_app(add_wsgi_middleware(application))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 115, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/django.zip/django/core/handlers/wsgi.py", line 230, in __call__
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/django.zip/django/core/handlers/base.py", line 40, in load_middleware
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/django.zip/django/utils/importlib.py", line 35, in import_module
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/appengine_django/auth/middleware.py", line 19, in <module>
    from appengine_django.auth.models import User
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/appengine_django/auth/models.py", line 170, in <module>
    class Message(BaseModel):
  File "/base/data/home/apps/lmd-v2/1.347617628611527644/appengine_django/auth/models.py", line 172, in Message
    user = db.ReferenceProperty(User)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 3118, in __init__
    raise KindError('reference_class must be Model or _SELF_REFERENCE')

What version of the product are you using? On what operating system?

Running on appengine 1.4.1  and appengine-django r109

Please provide any additional information below.
The app seems to run fine besides this, but I would like to add the user to 
each request. I am able to work with the user if i grab it in each view, but 
that is repetitive. I should be able to be added in the middleware,  and 
therefore in context_processors

I believe i have supplied all information. Let me know if you need anything 
else.

Original issue reported on code.google.com by MattyMat...@gmail.com on 14 Jan 2011 at 4:18

GoogleCodeExporter commented 8 years ago
FYI, I got this message in a different codebase (registration) when the code 
was using Google's ReferenceProperty:

    user = db.ReferenceProperty(User, verbose_name=_('user'))

instead of Django's ForeignKey:

    user = models.ForeignKey(User, unique=True, verbose_name=_('user'))

I think Google's ReferenceProperty was getting a Django User object and choking.

Original comment by dfran...@gmail.com on 18 Sep 2011 at 1:15