开发者

builtin password reset view problem in django1.3

Hi am absolutely new to django,Now I am tring for builtin reset password view..

I follow the link link But I got the error when I click on reset password button at /password_reset/ :

error at /accounts/password_reset/

[Errno 10061] No connection could be made because the target machine actively refused it.
Exception Location: C:开发者_JAVA百科\Python27\lib\socket.py in create_connection, line 571


  'urls.py'

(r'^accounts/password_reset$','django.contrib.auth.views.password_reset','template_name':'user/password_reset_form.html','email_template_name':'user/password_reset_email.html'}),

(r'^accounts/password/reset/confirm/(?P[0-9A-Za-z]{1,13})-(?P[0-9Aa-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name' : 'user/password_reset.html', 'post_reset_redirect': '/logout/' }),

     (r'^accounts/password_reset/done/$',<b>'django.contrib.auth.views.password_reset_done'</b>,{'template_name':'user/password_reset_done.html'}),


    (r'^accounts/change_password/$',<b> 'password_change'</b>, {'post_change_redirect' : '/accounts/change_password/done/'}),

    (r'^accounts/change_password/done/$',<b> 'password_change_done'</b>,{'template_name':'user/password_change_done.html'}),


<b>password_reset_email.html</b>


{% extends 'base.html'%}
{% block content%}
{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}
{% endblock %}

I add necessary templates in the folder 'user'.

Please help me,Thanks in advance.


As rdegges said, it's a connection error. Check which port the request is trying to access, and make sure windows firewall is set up to receive on that port. You can check the port by looking through django's traceback page, and looking at the "local vars".

From the looks of it, it's an email port. Take another look at the traceback and look out for django trying to send a request to port 25. If it does, make sure your port 25 is configured to receive.

Also, you'll need a makeshift SMTP server for testing purposes because you probably wouldn't want to be using a real one. Just have this running in a separate command prompt window while you're running django, and any emails that django tries to send through your port 25 will be saved in an "emails" folder in the working directory.

#/usr/bin/env python

from datetime import datetime
import asyncore
from smtpd import SMTPServer

class EmlServer(SMTPServer):
    no = 0
    def process_message(self, peer, mailfrom, rcpttos, data):
        filename = '%s-%d.eml' % (datetime.now().strftime('%Y%m%d%H%M%S'), self.no)
        f = open(filename, 'w')
        f.write(data)
        f.close()
        print '%s saved.' % filename
        self.no += 1


def run():
    foo = EmlServer(('localhost', 25), None)
    try:
        asyncore.loop()
    except KeyboardInterrupt:
        pass


if __name__ == '__main__':

    from os.path import exists, join
    from os import mkdir, chdir, getcwd

    target_directory = join( getcwd(), "emails" )
    if exists(target_directory):
        chdir(target_directory)
    else:
        try:
            mkdir(target_directory)
        except OSError:
            from sys import exit
            exit("The containing folder couldn't be created, check your permissions.")
        chdir(target_directory)
    print "Using directory %s" % target_directory

    run()


The error you're getting is a connection error--that means that the server you're using to run your Django site is likely not working correctly. Here are some things you can try on your Django server:

  • If you're running your Django site via python manage.py runserver, you can try to simply re-run that command.
  • If you're running your site via a webserver like apache, try restarting apache.

If neither of those work, post a comment and let me know what operating system you're running your site on, and how you're running it, and we can do further debugging.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜