lig / django-registration-me

DEPRECATED in favour of https://github.com/lig/regme. A user-registration application for Django (MongoEngine rework).
https://bitbucket.org/ubernostrum/django-registration/
BSD 3-Clause "New" or "Revised" License
21 stars 7 forks source link

problem with password_reset #2

Closed ruandao closed 12 years ago

ruandao commented 12 years ago

I get error with auth_password_reset when call for auth.password_reset, it will use auth.forms.PasswordResetForm, how ever, PasswordResetForm was bound with auth.models.User model which will raise a DATABASE error as I was use mongoengine backend

look this:

File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/contrib/auth/forms.py" in clean_email 
    205.         if not len(self.users_cache):

as I found on django.contrib.auth.form

class PasswordResetForm(forms.Form): 
    ....
    def clean_email(self):
        """
        Validates that an active user exists with the given email address.
        """
        email = self.cleaned_data["email"]
        self.users_cache = ***User.objects***.filter(email__iexact=email,
                                           is_active=True)                
        if not len(self.users_cache):  
            raise forms.ValidationError(self.error_messages['unknown'])
        if any((user.password == UNUSABLE_PASSWORD)
               for user in self.users_cache): 
            raise forms.ValidationError(self.error_messages['unusable'])
        return email

Environment:

Request Method: POST
Request URL: http://localhost:8000/accounts/password/reset/

Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'registration',
 'bussiness')
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 "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/contrib/auth/views.py" in password_reset
  149.         if form.is_valid():
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/forms/forms.py" in is_valid
  124.         return self.is_bound and not bool(self.errors)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/forms/forms.py" in _get_errors
  115.             self.full_clean()
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
  270.         self._clean_fields()
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/forms/forms.py" in _clean_fields
  290.                     value = getattr(self, 'clean_%s' % name)()
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/contrib/auth/forms.py" in clean_email
  205.         if not len(self.users_cache):
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  85.                 self._result_cache = list(self.iterator())
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  291.         for row in compiler.results_iter():
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  763.         for rows in self.execute_sql(MULTI):
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  808.             sql, params = self.as_sql()
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in as_sql
  71.         out_cols = self.get_columns(with_col_aliases)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in get_columns
  218.                     col_aliases)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in get_default_columns
  306.                 r = '%s.%s' % (qn(alias), qn2(field.column))
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in quote_name_unless_alias
  49.         r = self.connection.ops.quote_name(name)
File "/home/yan/env/haoyoubang/local/lib/python2.7/site-packages/django/db/backends/dummy/base.py" in complain
  15.     raise ImproperlyConfigured("settings.DATABASES is improperly configured. "

Exception Type: ImproperlyConfigured at /accounts/password/reset/
Exception Value: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation     for more details.
lig commented 12 years ago

Looks like real bug. Thank you for reporting.

lig commented 12 years ago

Fixed in master.

@ruandao please test and confirm that this is fixed.

lig commented 12 years ago

Fix released in version 0.7.2.