[GH-ISSUE #250] Internal Server Error: /accounts/password_reset/ #210

Closed
opened 2026-02-26 09:36:33 +03:00 by kerem · 7 comments
Owner

Originally created by @ThomasWaldmann on GitHub (Jan 4, 2016).
Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/250

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)}>
Originally created by @ThomasWaldmann on GitHub (Jan 4, 2016). Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/250 ``` 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)}> ```
kerem closed this issue 2026-02-26 09:36:33 +03:00
Author
Owner

@ThomasWaldmann commented on GitHub (Aug 27, 2016):

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?

<!-- gh-comment-id:242934479 --> @ThomasWaldmann commented on GitHub (Aug 27, 2016): 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?
Author
Owner

@ThomasWaldmann commented on GitHub (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).
<!-- gh-comment-id:249373781 --> @ThomasWaldmann commented on GitHub (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).
Author
Owner

@ThomasWaldmann commented on GitHub (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.

<!-- gh-comment-id:249376580 --> @ThomasWaldmann commented on GitHub (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.
Author
Owner

@ThomasWaldmann commented on GitHub (Sep 24, 2016):

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

<!-- gh-comment-id:249377162 --> @ThomasWaldmann commented on GitHub (Sep 24, 2016): Hmm, that crashes if i rename the template of django.admin. So, is it first match for the templates?
Author
Owner

@ThomasWaldmann commented on GitHub (Sep 24, 2016):

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

<!-- gh-comment-id:249379887 --> @ThomasWaldmann commented on GitHub (Sep 24, 2016): Note to self: I modified the base.py in the prod install, continue with experiments after other email problem is fixed.
Author
Owner

@elnappo commented on GitHub (Dec 27, 2016):

for me, this fixes the problem (until https://github.com/macropin/django-registration/issues/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',
 )
<!-- gh-comment-id:269393094 --> @elnappo commented on GitHub (Dec 27, 2016): for me, this fixes the problem (until https://github.com/macropin/django-registration/issues/140 is resolved): ```diff 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', ) ```
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 21, 2017):

works! \o/

<!-- gh-comment-id:274212602 --> @ThomasWaldmann commented on GitHub (Jan 21, 2017): works! \o/
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nsupdate.info-nsupdate-info#210
No description provided.