Thanks... I tried... everythings...
It worked..On 10 April 2017 at 13:21, ludovic coues <couesl@gmail.com> wrote:
That should be all the information needed to fix the problem :)TL:DR:use `{{ protocol }}://{{ domain }}{% url 'user_management:password_reset_confirm' uidb64=uid token=token %}` on line 5 of your email template. Long answer:The amount of information you provided last time would have been enough for my gut feeling, which is the same as the tl;dr. But I needed pretty much everything you have given here to be sure :)The traceback is pretty much useless to finding the origin of the error with template. That's why there is a Template error section. In you case, as you can guess, django try to find a named url but get nothing. To know why, we need to dive into the source and the traceback will be our guide.Starting with the end, the two last function, _reverse_with_prefix and reverse are internal to django routing. I let them alone.Next one live in defaulttags and cause issue at a call to reverse. I believe that it's the url template tag. I'm mainly curious about the current_app argument in reverse. I know that url name can take the form "app:name". In your case, that would be "user_management:password_reset_confirm". The current_app argument come from the context property of the tag object [1]. When looking at the traceback, two things stand out for the few followings lines. They all live in the template module and they all have a context argument. So I skip them.Next stop is send_mail in contrib/auth/forms.py. We get out of the template module but we still have the context argument, which disappear in the following line. Look like a good place to find the value of context.Oops, look like I was off by one. send_mail take the context argument from save, same file. The call to send_mail taking 4 lines, the context argument have been stripped from the line in the traceback. But the context is defined in the save method [2].You will notice it's a simple dict without a request key. But if you have looked at how the URL tag define the current_app, you'll notice it make use of the request key of the context.That's the root of your problem. Email are generated without a request. And without a request, you need to specify the full name of url, as you don't have access to the current_app. By the way, current_app is matching app_name you specify in your URL.py file. That's why I asked the full urls.py the first time.I hope I'm clear and that will help you :)All you need to remember is that sometimes, you need to specify the full name of an url.--2017-04-10 7:09 GMT+02:00 sarfaraz ahmed <findsarfaraz@gmail.com>:--I am using password_reset view when I am getting this error. I checked password_reset view and found i am getting error during this lineI have attempted to make CustomUser model in django to signin using email.Hello Friends,
form.save(**opts)in password_resetURL.py
------------------------------------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---- ------------------------------------------------------------ ------------------------------ -- from django.conf.urls import url,include
from django.conf.urls import url
from django.conf.urls import include
from . import views
from views import *
from django.contrib.auth import views as auth_views
from django.contrib.auth.views import password_reset,password_reset_done
app_name ="user_management"
urlpatterns = [
url(r'^login/',login,name='login'),
url(r'^auth_view/',auth_view, name='auth_view'),
url(r'^signup_success/',signup_success,name='signup_success' ),
url(r'^signup/',signup,name='signup'),
url(r'^logout/',logout,name='logout'),
url(r'^signup_confirm/(?P<activation_key>\w+)',signup_confir m,name='signup_confirm'),
url(r'^account_info/',account_info,name='account_info'),
url(r'^user_profile/',user_profile,name='user_profile'),
url(r'^address/',address,name='address'),
url(r'^change_password/',change_password,name='change_passwo rd'),
url(r'^add_address/',add_address,name='add_address'),
url(r'^edit_address/(?P<id>\d+)',edit_address,name='edit_add ress'),
url(r'^delete_address/(?P<id>\d+)',delete_address,name='dele te_address'),
url(r'^change_password/',change_password,name='change_passwo rd'),
url(r'^email_test/',email_test,name='email_test'),
url(r'^password_reset/$', auth_views.password_reset,{'post_reset_redirect':'/password_ reset/done','template_name':' user_management/password_ reset.html','email_template_ name':'user_management/ password_reset_email.html'} , name='password_reset'),
url(r'^password_reset/done/$', auth_views.password_reset_done, {'template_name':'user_managem ent/password_reset_done.html'} ,name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za- z]{1,13}-[0-9A-Za-z]{1,20})/$' ,
auth_views.password_reset_confirm,{'template_name':'user_ managment/password_reset_confi rm.html'},name='password_reset _confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete, {'template_name':'user_managem ent/password_reset_complete. html'}, name='password_reset_complete' ),
]
------------------------------------------------------------ ------------------------------ ------------------------------ ----------------------- NoReverseMatch at /password_reset/
Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'4l3-29face0d2514fc5a70e4'}' not found. 0 pattern(s) tried: []
Request Method: POST Request URL: http://127.0.0.1:8000/password _reset/ Django Version: 1.10.5 Exception Type: NoReverseMatch Exception Value: Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'4l3-29face0d2514fc5a70e4'}' not found. 0 pattern(s) tried: []Exception Location: C:\Python27\lib\site-packages\ django-1.10.5-py2.7.egg\django \urls\resolvers.py in _reverse_with_prefix, line 392 Python Executable: C:\Python27\python.exe Python Version: 2.7.9 Python Path: ['G:\\DJANGO_Project\\project1', 'C:\\Python27\\lib\\site-packa ges\\django_extensions-1.4.9- py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\six-1.9.0-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\werkzeug-0.9.6-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\django_cron-0.3.5-py2.7. egg', 'C:\\Python27\\lib\\site-packa ges\\django_common_helpers-0. 6.3-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\south-1.0.2-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\django_crontab-0.6.0-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\django_kronos-0.6-py2.7. egg', 'C:\\Python27\\lib\\site-packa ges\\python_crontab-1.9.1-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\django_chronograph-0.3.1- py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\python_dateutil-1.5-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\crontab-0.20.2-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\django_chroniker-0.6.8- py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\psutil-2.2.0-py2.7-win32. egg', 'C:\\Python27\\lib\\site-packa ges\\celery-3.1.17-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\kombu-3.0.24-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\billiard-3.3.0.19-py2.7- win32.egg', 'C:\\Python27\\lib\\site-packa ges\\pytz-2014.10-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\amqp-1.4.6-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\anyjson-0.3.3-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\django_celery-3.1.16-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\django_kombu-0.9.4-py2.7. egg', 'C:\\Python27\\lib\\site-packa ges\\django_windows_tools-0.1. 1-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\elasticsearch-1.3.0-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\urllib3-1.10.1-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\beautifulsoup-3.2.1-py2. 7.egg', 'C:\\Python27\\lib\\site-packa ges\\xmlutils-1.1-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\pillow-2.9.0-py2.7-win32. egg', 'C:\\Python27\\lib\\site-packa ges\\requests-2.7.0-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\openpyxl-2.3.4-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\et_xmlfile-1.0.1-py2.7. egg', 'C:\\Python27\\lib\\site-packa ges\\jdcal-1.2-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\xlrd-0.9.4-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\webcolors-1.5-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\bpython-0.15-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\greenlet-0.4.9-py2.7- win32.egg', 'C:\\Python27\\lib\\site-packa ges\\curtsies-0.2.6-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\pygments-2.1.3-py2.7.egg' , 'C:\\Python27\\lib\\site-packa ges\\wcwidth-0.1.6-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\blessings-1.6-py2.7.egg', 'C:\\Python27\\lib\\site-packa ges\\dnspython-1.14.0-py2.7. egg', 'C:\\Python27\\lib\\site-packa ges\\django-1.10.5-py2.7.egg', 'C:\\Windows\\system32\\python 27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packa ges', 'C:\\Python27\\lib\\site-packa ges\\win32', 'C:\\Python27\\lib\\site-packa ges\\win32\\lib', 'C:\\Python27\\lib\\site-packa ges\\Pythonwin'] Server time: Mon, 10 Apr 2017 05:02:00 +0000 Error during template rendering
In template
G:\DJANGO_Project\project1\use, error at line 5r_management\templates\user_ management\password_reset_ email.html Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'4l3-29face0d2514fc5a70e4'}' not found. 0 pattern(s) tried: []
1 {% autoescape off %} 2 To initiate the password reset process for your {{ user.get_username }} Arham Account, 3 click the link below: 4 5 {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} 6 7 If clicking the link above doesn't work, please copy and paste the URL in a new browser 8 window instead. 9 10 Sincerely, 11 The Arham Collections 12 {% endautoescape %}
------------------------------------------------------------ ------------------------------ ------------------------------ ------------------------------ --
------------------------------------------------------------ ------------------------------ ------------------------------ ------------------------------ ----- Trace back------------------------------------------------------------ ------------------------------ ------------------------------ ------------------------------ --
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/password_reset/
Django Version: 1.10.5
Python Version: 2.7.9
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main_app',
'user_management',
'product_management']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template error:
In template G:\DJANGO_Project\project1\user_management\templates\user_ management\password_reset_ email.html, error at line 5
Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'4l3-29face0d2514fc5a70e4'}' not found. 0 pattern(s) tried: [] 1 : {% autoescape off %}
2 : To initiate the password reset process for your {{ user.get_username }} Arham Account,
3 : click the link below:
4 :
5 : {{ protocol }}://{{ domain }} {% url 'password_reset_confirm' uidb64=uid token=token %}
6 :
7 : If clicking the link above doesn't work, please copy and paste the URL in a new browser
8 : window instead.
9 :
10 : Sincerely,
11 : The Arham Collections
12 : {% endautoescape %}
Traceback:
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\core\handlers\exception .py" in inner
39. response = get_response(request)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\contrib\auth\views.py" in inner
47. return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\utils\decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\contrib\auth\views.py" in password_reset
212. form.save(**opts)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\contrib\auth\forms.py" in save
291. user.email, html_email_template_name=html_email_template_name,
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\contrib\auth\forms.py" in send_mail
240. body = loader.render_to_string(email_template_name, context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\loader.py" in render_to_string
68. return template.render(context, request)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\backends\djang o.py" in render
66. return self.template.render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in render
208. return self._render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in _render
199. return self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in render
994. bit = node.render_annotated(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in render_annotated
961. return self.render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\defaulttags. py" in render
39. output = self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in render
994. bit = node.render_annotated(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\base.py" in render_annotated
961. return self.render(context)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\template\defaulttags. py" in render
439. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\urls\base.py" in reverse
91. return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\ django\urls\resolvers.py" in _reverse_with_prefix
392. (lookup_view_s, args, kwargs, len(patterns), patterns)
Exception Type: NoReverseMatch at /password_reset/
Exception Value: Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'4l3-29face0d2514fc5a70e4'}' not found. 0 pattern(s) tried: []
------------------------------------------------- I hope this information is enough--Thanks with regards,
Sarfaraz Ahmed
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEPJdiwPcS1p .Sef2m6h%2BpGecvHfVJAEf-wXGmmvT 0BPGpKbBBA%40mail.gmail.com
For more options, visit https://groups.google.com/d/optout .
--
Cordialement, Ludovic Coues
+33 6 14 87 43 42
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG% .2BTZKxo%3DXFOjt2Cfh% 2BHemN9K3QFpNLJ8Q7viggJuJ_ v4LQw%40mail.gmail.com
For more options, visit https://groups.google.com/d/optout .
--
Thanks with regards,
Sarfaraz Ahmed
Sarfaraz Ahmed
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEPJdiw3qMBSx0cYOGDfPBsZQLm40gebr1VxyA9t3xGyZdnXbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment