django-nonrel / mongodb-engine

Django MongoDB Backend
http://www.django-nonrel.org/
862 stars 211 forks source link

error creating or editing users (admin) #57

Closed ademarcrotti closed 13 years ago

ademarcrotti commented 13 years ago

Hi,

On the admin django when I try to edit or create an user it gives me the error:

DatabaseError at /admin/auth/user/4e1ecd9f16a8b80e44000014/ This query is not supported by the database.

jonashaag commented 13 years ago

Please show the full traceback.

ademarcrotti commented 13 years ago

the backtrace:

Environment:

Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/4e1ece1616a8b80e5a000004/

Django Version: 1.3 Python Version: 2.7.1 Installed Applications: ['django_mongodb_engine', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'bookmarks', 'userprofile', 'demoprofile'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
  2. return self.admin_site.admin_view(view)(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  3. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  4. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  5. return view(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  6. return bound_func(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  7. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
  8. return func(self, _args2, *_kwargs2) File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
  9. res = func(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in change_view
  10. form = ModelForm(instance=obj) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py" in init
  11. super(UserChangeForm, self).init(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in init
  12. object_data = model_to_dict(instance, opts.fields, opts.exclude) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in model_to_dict
  13. data[f.name] = [obj.pk for obj in f.value_from_object(instance)] File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _result_iter
  14. self._fill_cache() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fill_cache
  15. self._result_cache.append(self._iter.next()) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
  16. for row in compiler.results_iter(): File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in results_iter
  17. self.check_query() File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in check_query
  18. raise DatabaseError('This query is not supported by the database.')

Exception Type: DatabaseError at /admin/auth/user/4e1ece1616a8b80e5a000004/ Exception Value: This query is not supported by the database.

ademarcrotti commented 13 years ago

added djangotoolbox to the installed_apps and it's working. sorry.

jonashaag commented 13 years ago

Are you sure having djangotoolbox in the INSTALLED_APPS made the difference? That shouldn't be required actually...

ademarcrotti commented 13 years ago

Well, i think that djangotoolbox changed the user form on admin. It started working after adding it.

ademarcrotti commented 13 years ago

Actually this error is happenning again on groups, look:

Environment:

Request Method: GET Request URL: http://localhost:8000/admin/auth/group/4e1f063816a8b81761000000/

Django Version: 1.3 Python Version: 2.7.1 Installed Applications: ['django_mongodb_engine', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'bookmarks', 'userprofile', 'demoprofile', 'djangotoolbox', 'registration'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
  2. return self.admin_site.admin_view(view)(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  3. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  4. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  5. return view(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  6. return bound_func(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  7. response = view_func(request, _args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
  8. return func(self, _args2, *_kwargs2) File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
  9. res = func(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in change_view
  10. form = ModelForm(instance=obj) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in init
  11. object_data = model_to_dict(instance, opts.fields, opts.exclude) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in model_to_dict
  12. data[f.name] = [obj.pk for obj in f.value_from_object(instance)] File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _result_iter
  13. self._fill_cache() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fill_cache
  14. self._result_cache.append(self._iter.next()) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
  15. for row in compiler.results_iter(): File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in results_iter
  16. self.check_query() File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in check_query
  17. raise DatabaseError('This query is not supported by the database.')

Exception Type: DatabaseError at /admin/auth/group/4e1f063816a8b81761000000/ Exception Value: This query is not supported by the database.

jonashaag commented 13 years ago

Sorry, can not reproduce. Are you sure the Django version being used is Django-nonrel (and not Django "mainline")? Please try in a fresh virtualenv. If that doesn't make any difference, I need to know your exact setup (settings, urls, ...).

ademarcrotti commented 13 years ago

I tryed a fresh virtualenv, reinstall django-nonrel, djangotoolbox and mongodb-engine in a new app and the error still happens.

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/auth/user/4e20142616a8b80c8f000010/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django_mongodb_engine',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
  307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  197.             return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  28.             return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
  24.                 return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
  217.                 res = func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in change_view
  992.             form = ModelForm(instance=obj)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py" in __init__
  56.         super(UserChangeForm, self).__init__(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in __init__
  237.             object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in model_to_dict
  127.                 data[f.name] = [obj.pk for obj in f.value_from_object(instance)]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _result_iter
  107.                 self._fill_cache()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fill_cache
  774.                     self._result_cache.append(self._iter.next())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
  275.         for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in results_iter
  215.         self.check_query()
File "/usr/local/lib/python2.7/dist-packages/djangotoolbox-0.9.2-py2.7.egg/djangotoolbox/db/basecompiler.py" in check_query
  262.             raise DatabaseError('This query is not supported by the database.')

Exception Type: DatabaseError at /admin/auth/user/4e20142616a8b80c8f000010/
Exception Value: This query is not supported by the database.
setting.py
# Django settings for test_ project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'test_mongodb',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': 'localhost',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '27017',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = '4e20142616a8b80c8f00001d'

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '&_bvtyvuhba^w^js3&qr=*kcn#84f#8(#qfqep^kl2$#a!voo!'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'test_.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

urls.py
from django.conf.urls.defaults import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'test_.views.home', name='home'),
    # url(r'^test_/', include('test_.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)
jonashaag commented 13 years ago

Alright, I can reproduce this.

jonashaag commented 13 years ago

See the last message in this thread on why djangotoolbox needs to be in INSTALLED_APPS: http://groups.google.com/group/django-non-relational/browse_thread/thread/ee6fc65f2581274c

I opened #58 so that I remember to document this trick.