Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error: /accounts/password_reset/ #250

Closed
ThomasWaldmann opened this issue Jan 4, 2016 · 7 comments · Fixed by #291
Closed

Internal Server Error: /accounts/password_reset/ #250

ThomasWaldmann opened this issue Jan 4, 2016 · 7 comments · Fixed by #291
Milestone

Comments

@ThomasWaldmann
Copy link
Member

Internal Server Error: /accounts/password_reset/
Traceback (most recent call last):
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/contrib/auth/views.py", line 182, in password_reset
    form.save(**opts)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 256, in save
    html_email_template_name=html_email_template_name)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 206, in send_mail
    body = loader.render_to_string(email_template_name, context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/loader.py", line 99, in render_to_string
    return template.render(context, request)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/backends/django.py", line 74, in render
    return self.template.render(context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/base.py", line 210, in render
    return self._render(context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/base.py", line 202, in _render
    return self.nodelist.render(context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/base.py", line 905, in render
    bit = self.render_node(node, context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/base.py", line 919, in render_node
    return node.render(context)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 507, in render
    six.reraise(*exc_info)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 493, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 578, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/srv/nsupdate.info/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 495, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
NoReverseMatch: Reverse for 'auth_password_reset_confirm' with arguments '('XXXXXX', u'xxx-xxxxxxxxxxxxxx')' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Request repr(): 
<WSGIRequest
path:/accounts/password_reset/,
GET:<QueryDict: {}>,
POST:<QueryDict: {u'email': [u'xxxxxxx1994@gmail.com'], u'csrfmiddlewaretoken': [u'xxxxxxxxxxxxxxxxxxxxxxx']}>,
COOKIES:{'csrftoken': 'xxxxxxxxxxxxxxxxxx',
 'sessionid': 'xxxxxxxxxxxxxxxxxxxxxxxxx'},
META:{'CONTENT_LENGTH': '82',
 'CONTENT_TYPE': 'application/x-www-form-urlencoded',
 u'CSRF_COOKIE': u'xxxxxxxxxxxxxxxxxxxxxxxxx',
 'DOCUMENT_ROOT': '/srv/nsupdate.info/htdocs',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
 'HTTP_CACHE_CONTROL': 'max-age=0',
 'HTTP_CONNECTION': 'close',
 'HTTP_CONTENT_LENGTH': '82',
 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded',
 'HTTP_COOKIE': 'sessionid=xxxxxxxxxxxxxxxxxxxxxxx; csrftoken=xxxxxxxxxxxxxxxxxxxx',
 'HTTP_HOST': 'www.nsupdate.info',
 'HTTP_ORIGIN': 'https://www.nsupdate.info',
 'HTTP_REFERER': 'https://www.nsupdate.info/accounts/password_reset/',
 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36',
 'HTTP_X_FORWARDED_FOR': '2401:e800:xxxx:xxxx:a053:f2ea:xxxx:xxxx',
 'HTTP_X_FORWARDED_PROTO': 'https',
 'HTTP_X_REAL_IP': '2401:e800:xxxx:xxxx:a053:f2ea:xxxx:xxxx',
 'PATH_INFO': u'/accounts/password_reset/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '2401:e800:xxxx:xxxx:a053:f2ea:xxxx:xxxx',
 'REMOTE_PORT': '',
 'REQUEST_METHOD': 'POST',
 'REQUEST_URI': '/accounts/password_reset/',
 u'SCRIPT_NAME': u'',
 'SERVER_NAME': 'www.nsupdate.info',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'UWSGI_APPID': 'nsupdate',
 'UWSGI_SCHEME': 'https',
 'uwsgi.core': 3,
 'uwsgi.node': 'web.thinkmo.de',
 'uwsgi.version': '2.0.7-debian',
 'wsgi.errors': <open file 'wsgi_errors', mode 'w' at 0x7f53083a4300>,
 'wsgi.file_wrapper': <built-in function uwsgi_sendfile>,
 'wsgi.input': <uwsgi._Input object at 0x7f52fee71840>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': True,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'https',
 'wsgi.version': (1, 0)}>
@ThomasWaldmann
Copy link
Member Author

This is a very strange error.

If I place a identical copy of:
env/lib/python2.7/site-packages/django/contrib/admin/templates/registration/password_reset_email.html
at
repo/nsupdate/accounts/templates/registration/password_reset_email.html
it works with d-r-r 1.4.

If I remove the copy, it crashes again (see traceback above).

I checked permissions, read permissions are there for both files.

WAT?

@ThomasWaldmann ThomasWaldmann added this to the 0.12 release milestone Aug 27, 2016
@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Sep 24, 2016

Solved, Amin helped me finding it:

  • env/lib/python2.7/site-packages/registration/templates/registration/password_reset_email.html uses "auth_password_reset_confirm" (part of d-r-r)
  • env/lib/python2.7/site-packages/django/contrib/admin/templates/registration/password_reset_email.html uses the same template dir and filename (part of django).

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Sep 24, 2016

First try to fix this (as recommended by d-r-r docs and some fellow python devs):

diff --git a/nsupdate/settings/base.py b/nsupdate/settings/base.py
index 74876d2..2771fb5 100644
--- a/nsupdate/settings/base.py
+++ b/nsupdate/settings/base.py
@@ -156,10 +156,12 @@ ROOT_URLCONF = 'nsupdate.urls'
 WSGI_APPLICATION = 'nsupdate.wsgi.application'

 INSTALLED_APPS = (
+    'django.contrib.admin',
+    'django.contrib.sites',
+    'registration',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
-    'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.humanize',
@@ -170,8 +172,6 @@ INSTALLED_APPS = (
     'nsupdate.api',
     'nsupdate.main',
     'bootstrapform',
-    'registration',
-    'django.contrib.admin',
     'django_extensions',
 )

Last match is the one that is used when seeking the right template.

@ThomasWaldmann
Copy link
Member Author

Hmm, that crashes if i rename the template of django.admin. So, is it first match for the templates?

@ThomasWaldmann
Copy link
Member Author

Note to self:
I modified the base.py in the prod install, continue with experiments after other email problem is fixed.

@elnappo
Copy link
Member

elnappo commented Dec 27, 2016

for me, this fixes the problem (until macropin/django-registration#140 is resolved):

diff --git a/nsupdate/settings/base.py b/nsupdate/settings/base.py
index bf2f1e3..cccd281 100644
--- a/nsupdate/settings/base.py
+++ b/nsupdate/settings/base.py

@@ -172,8 +172,8 @@ INSTALLED_APPS = (
     'nsupdate.api',
     'nsupdate.main',
     'bootstrapform',
-    'registration',
     'django.contrib.admin',
+    'registration',
     'django_extensions',
 )

@ThomasWaldmann
Copy link
Member Author

works! \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants