def test_utils(self): md5 = get_md5('test') self.assertIsNotNone(md5) c = CommonMarkdown.get_markdown(''' # Title1 ```python import os ``` [url](https://www.lylinux.net/) [ddd](http://www.baidu.com) ''') self.assertIsNotNone(c) d = {'d': 'key1', 'd2': 'key2'} data = parse_dict_to_url(d) self.assertIsNotNone(data) render = BlogMarkDownRenderer() s = render.autolink('http://www.baidu.com') self.assertTrue(s.find('nofollow') > 0) s = render.link('http://www.baidu.com', 'test', 'test') self.assertTrue(s.find('nofollow') > 0)
def emailconfirm(request, id, sign): if not sign: return HttpResponseForbidden() if not get_md5(settings.SECRET_KEY + str(id) + settings.SECRET_KEY).upper() == sign.upper(): return HttpResponseForbidden() oauthuser = get_object_or_404(OAuthUser, pk=id) author = get_user_model().objects.get(pk=oauthuser.author_id) if oauthuser.email and author.email: login(request, author) return HttpResponseRedirect('/') author.set_password('$%^Q1W2E3R4T5Y6,./') author.email = oauthuser.email author.save() login(request, author) site = Site.objects.get_current().domain send_email( '恭喜您绑定成功!', ''' <p>恭喜您,您已经成功绑定您的邮箱,您可以使用{type}来直接免密码登录本网站.欢迎您继续关注本站,地址是</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} '''.format(type=oauthuser.type, url='http://' + site), [ oauthuser.email, ]) return HttpResponseRedirect('/')
def form_valid(self, form): email = form.cleaned_data['email'] oauthid = form.cleaned_data['oauthid'] oauthuser = get_object_or_404(OAuthUser, pk=oauthid) oauthuser.email = email oauthuser.save() sign = get_md5(settings.SECRET_KEY + str(oauthuser.id) + settings.SECRET_KEY) site = get_current_site().domain if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('oauth:email_confirm', kwargs={ 'id': oauthid, 'sign': sign }) url = "http://{site}{path}".format(site=site, path=path) content = """ <p>请点击下面链接绑定您的邮箱</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} """.format(url=url) send_email(emailto=[ email, ], title='绑定您的电子邮箱', content=content) url = reverse('oauth:bindsuccess', kwargs={'oauthid': oauthid}) url = url + '?type=email' return HttpResponseRedirect(url)
def form_valid(self, form): email = form.cleaned_data['email'] oauthid = form.cleaned_data['oauthid'] oauthuser = get_object_or_404(OAuthUser, pk=oauthid) oauthuser.email = email oauthuser.save() sign = get_md5(settings.SECRET_KEY + str(oauthuser.id) + settings.SECRET_KEY) site = get_current_site().domain if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('oauth:email_confirm', kwargs={ 'id': oauthid, 'sign': sign }) url = "http://{site}{path}".format(site=site, path=path) content = """ <p>Please click the link below to link your email</p> <a href="{url}" rel="bookmark">{url}</a> Thank you again! <br /> If the link above cannot be opened, please copy this link to your browser. {url} """.format(url=url) send_email(emailto=[ email, ], title='Link your email', content=content) url = reverse('oauth:bindsuccess', kwargs={'oauthid': oauthid}) url = url + '?type=email' return HttpResponseRedirect(url)
def form_valid(self, form): email = form.cleaned_data['email'] oauthid = form.cleaned_data['oauthid'] oauthuser = get_object_or_404(OAuthUser, pk=oauthid) oauthuser.email = email oauthuser.save() sign = get_md5(settings.SECRET_KEY + str(oauthuser.id) + settings.SECRET_KEY) site = Site.objects.get_current().domain if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('oauth:email_confirm', kwargs={ 'id': oauthid, 'sign': sign }) url = "http://{site}{path}".format(site=site, path=path) content = """ <p>请点击下面链接绑定您的邮箱</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} """.format(url=url) send_email(emailto=[email, ], title='绑定您的电子邮箱', content=content) url = reverse('oauth:bindsuccess', kwargs={ 'oauthid': oauthid }) url = url + '?type=email' return HttpResponseRedirect(url)
def fileupload(request): """ This method needs to write the caller to upload the picture. This method only provides the picture bed function. :param request: :return: """ if request.method == 'POST': sign = request.GET.get('sign', None) if not sign: return HttpResponseForbidden() if not sign == get_md5(get_md5(settings.SECRET_KEY)): return HttpResponseForbidden() response = [] for filename in request.FILES: timestr = datetime.datetime.now().strftime('%Y/%m/%d') imgextensions = ['jpg', 'png', 'jpeg', 'bmp'] fname = u''.join(str(filename)) isimage = len([i for i in imgextensions if fname.find(i) >= 0]) > 0 blogsetting = get_blog_setting() basepath = r'{basedir}/{type}/{timestr}'.format( basedir=blogsetting.resource_path, type='files' if not isimage else 'image', timestr=timestr) if settings.TESTING: basepath = settings.BASE_DIR + '/uploads' url = 'https://mtuktarov.ru/{type}/{timestr}/{filename}'.format( type='files' if not isimage else 'image', timestr=timestr, filename=filename) if not os.path.exists(basepath): os.makedirs(basepath) savepath = os.path.join(basepath, filename) with open(savepath, 'wb+') as wfile: for chunk in request.FILES[filename].chunks(): wfile.write(chunk) if isimage: from PIL import Image image = Image.open(savepath) image.save(savepath, quality=20, optimize=True) response.append(url) return HttpResponse(response) else: return HttpResponse("only for post")
def test_image(self): import requests rsp = requests.get('https://www.python.org/static/img/[email protected]') imagepath = os.path.join(settings.BASE_DIR, 'python.png') with open(imagepath, 'wb') as file: file.write(rsp.content) rsp = self.client.post('/upload') self.assertEqual(rsp.status_code, 403) sign = get_md5(get_md5(settings.SECRET_KEY)) with open(imagepath, 'rb') as file: imgfile = SimpleUploadedFile('python.png', file.read(), content_type='image/jpg') form_data = {'python.png': imgfile} rsp = self.client.post('/upload?sign=' + sign, form_data, follow=True) self.assertEqual(rsp.status_code, 200) from DjangoBlog.utils import save_user_avatar, send_email send_email(['*****@*****.**'], 'testTitle', 'testContent') save_user_avatar('https://www.python.org/static/img/[email protected]') """
def form_valid(self, form): if form.is_valid(): user = form.save(False) user.is_active = False user.source = 'Register' user.save(True) site = get_current_site().domain sign = get_md5(get_md5(settings.SECRET_KEY + str(user.id))) if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('account:result') url = "http://{site}{path}?type=validation&id={id}&sign={sign}".format( site=site, path=path, id=user.id, sign=sign) content = """ <p>点击下面链接验证登录</p> <a href="{url}" rel="bookmark">{url}</a> 这个世界会好吗? <br /> 若上面链接无法打开,到浏览器中打开。 {url} """.format(url=url) send_email( emailto=[ user.email, ], title='验证电子邮箱', content=content) url = reverse('accounts:result') + \ '?type=register&id=' + str(user.id) return HttpResponseRedirect(url) else: return self.render_to_response({ 'form': form })
def handler(self): info = self.message.content if self.userinfo.isAdmin and info.upper() == 'EXIT': self.userinfo = WxUserInfo() self.savesession() return "退出成功" if info.upper() == 'ADMIN': self.userinfo.isAdmin = True self.savesession() return "输入管理员密码" if self.userinfo.isAdmin and not self.userinfo.isPasswordSet: passwd = settings.WXADMIN if settings.TESTING: passwd='123' if passwd.upper() == get_md5(get_md5(info)).upper(): self.userinfo.isPasswordSet = True self.savesession() return "验证通过,请输入命令或者要执行的命令代码:输入helpme获得帮助" else: if self.userinfo.Count >= 3: self.userinfo = WxUserInfo() self.savesession() return "超过验证次数" self.userinfo.Count += 1 self.savesession() return "验证失败,请重新输入管理员密码:" if self.userinfo.isAdmin and self.userinfo.isPasswordSet: if self.userinfo.Command != '' and info.upper() == 'Y': return cmdhandler.run(self.userinfo.Command) else: if info.upper() == 'HELPME': return cmdhandler.get_help() self.userinfo.Command = info self.savesession() return "确认执行: " + info + " 命令?" rsp = tuling.getdata(info) return rsp
def handler(self): info = self.message.content if self.userinfo.isAdmin and info.upper() == 'EXIT': self.userinfo = WxUserInfo() self.savesession() return "Выход успешен" if info.upper() == 'ADMIN': self.userinfo.isAdmin = True self.savesession() return "Введите пароль администратора" if self.userinfo.isAdmin and not self.userinfo.isPasswordSet: passwd = settings.WXADMIN if settings.TESTING: passwd = '123' if passwd.upper() == get_md5(get_md5(info)).upper(): self.userinfo.isPasswordSet = True self.savesession() return "Введите команду или код команды для выполнения: введите helpme для справки" else: if self.userinfo.Count >= 3: self.userinfo = WxUserInfo() self.savesession() return "Превышены допустимое число проверок" self.userinfo.Count += 1 self.savesession() return "Ошибка аутентификации. Пожалуйста, введите пароль администратора еще раз:" if self.userinfo.isAdmin and self.userinfo.isPasswordSet: if self.userinfo.Command != '' and info.upper() == 'Y': return cmdhandler.run(self.userinfo.Command) else: if info.upper() == 'HELPME': return cmdhandler.get_help() self.userinfo.Command = info self.savesession() return "Подтвердите выполнение: " + info + " команды?" rsp = tuling.getdata(info) return rsp
def handler(self): info = self.message.content if self.userinfo.isAdmin and info.upper() == 'EXIT': self.userinfo = WxUserInfo() self.savesession() return "退出成功" if info.upper() == 'ADMIN': self.userinfo.isAdmin = True self.savesession() return "輸入管理員密碼" if self.userinfo.isAdmin and not self.userinfo.isPasswordSet: passwd = settings.WXADMIN if settings.TESTING: passwd = '123' if passwd.upper() == get_md5(get_md5(info)).upper(): self.userinfo.isPasswordSet = True self.savesession() return "驗證通過,請輸入命令或者要執行的命令代碼:輸入helpme獲得幫助" else: if self.userinfo.Count >= 3: self.userinfo = WxUserInfo() self.savesession() return "超過驗證次數" self.userinfo.Count += 1 self.savesession() return "驗證失敗,請重新輸入管理員密碼:" if self.userinfo.isAdmin and self.userinfo.isPasswordSet: if self.userinfo.Command != '' and info.upper() == 'Y': return cmdhandler.run(self.userinfo.Command) else: if info.upper() == 'HELPME': return cmdhandler.get_help() self.userinfo.Command = info self.savesession() return "確認執行: " + info + " 命令?" rsp = tuling.getdata(info) return rsp
def handler(self): info = self.message.content if self.userinfo.isAdmin and info.upper() == 'EXIT': self.userinfo = WxUserInfo() self.savesession() return "退出成功" if info.upper() == 'ADMIN': self.userinfo.isAdmin = True self.savesession() return "输入管理员密码" if self.userinfo.isAdmin and not self.userinfo.isPasswordSet: passwd = settings.WXADMIN if settings.TESTING: passwd='123' if passwd.upper() == get_md5(get_md5(info)).upper(): self.userinfo.isPasswordSet = True self.savesession() return "验证通过,请输入命令或者要执行的命令代码:输入helpme获得帮助" else: if self.userinfo.Count >= 3: self.userinfo = WxUserInfo() self.savesession() return "超过验证次数" self.userinfo.Count += 1 self.savesession() return "验证失败,请重新输入管理员密码:" if self.userinfo.isAdmin and self.userinfo.isPasswordSet: if self.userinfo.Command != '' and info.upper() == 'Y': return cmdhandler.run(self.userinfo.Command) else: if info.upper() == 'HELPME': return cmdhandler.get_help() self.userinfo.Command = info self.savesession() return "确认执行: " + info + " 命令?" rsp = tuling.getdata(info) return rsp
def handler(self): info = self.message.content if self.userinfo.isAdmin and info.upper() == 'EXIT': self.userinfo = WxUserInfo() self.savesession() return "exit successfully" if info.upper() == 'ADMIN': self.userinfo.isAdmin = True self.savesession() return "Enter administrator password" if self.userinfo.isAdmin and not self.userinfo.isPasswordSet: passwd = settings.WXADMIN if settings.TESTING: passwd = '123' if passwd.upper() == get_md5(get_md5(info)).upper(): self.userinfo.isPasswordSet = True self.savesession() return "Verification passed, please enter the command or command code to be executed: enter helpme for help" else: if self.userinfo.Count >= 3: self.userinfo = WxUserInfo() self.savesession() return "Number of verifications exceeded" self.userinfo.Count += 1 self.savesession() return "Verification failed, please re-enter administrator password:"******"Confirm execution: " + info + " 命令?" rsp = tuling.getdata(info) return rsp
def account_result(request): type = request.GET.get('type') id = request.GET.get('id') user = get_object_or_404(get_user_model(), id=id) logger.info(type) if user.is_active: return HttpResponseRedirect('/') if type and type in ['register', 'validation']: if type == 'register': content = ''' Круто, что ты с нами! Осталось подтвердить указанный почтовый ящик {email} '''.format(email=user.email) title = 'Регистрация прошла успешно' else: c_sign = get_md5(get_md5(settings.SECRET_KEY + str(user.id))) sign = request.GET.get('sign') if sign != c_sign: return HttpResponseForbidden() user.is_active = True user.save() messages.success(request, 'Почта успешно подтверждена!') return HttpResponseRedirect('/')
def form_valid(self, form): if form.is_valid(): user = form.save(False) user.is_active = False user.source = 'Register' user.save(True) site = get_current_site().domain sign = get_md5(get_md5(settings.SECRET_KEY + str(user.id))) if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('account:result') url = "http://{site}{path}?type=validation&id={id}&sign={sign}".format( site=site, path=path, id=user.id, sign=sign) content = """ <p>请点击下面链接验证您的邮箱</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} """.format(url=url) send_email(emailto=[ user.email, ], title='验证您的电子邮箱', content=content) url = reverse('accounts:result') + '?type=register&id=' + str( user.id) logger.info('有人注册拉!!!==> 访客:{},已发送验证邮件.'.format(user.username)) return HttpResponseRedirect(url) else: return self.render_to_response({'form': form})
def form_valid(self, form): if form.is_valid(): user = form.save(False) user.is_active = False user.source = 'Register' user.save(True) site = get_current_site().domain sign = get_md5(get_md5(settings.SECRET_KEY + str(user.id))) if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('account:result') url = "http://{site}{path}?type=validation&id={id}&sign={sign}".format( site=site, path=path, id=user.id, sign=sign) content = render_template('confirm_email.j2', vars=locals()) subject = 'Подтвердите email адрес' if content is not None: send_email(emailto=[ user.email, ], title=subject, content=content, images={ "logo.png": "image/png", "mail_icon.png": "image/png" }) url = reverse('accounts:result') + '?type=register&id=' + str( user.id) messages.success( self.request, f"Новый аккаунт %s создан. Подтвердите свой почтовый ящик: %s" % (user.username, user.email)) return HttpResponseRedirect(url) else: messages.error(self.request, form.errors) return self.render_to_response({'form': form})
def form_valid(self, form): if form.is_valid(): user = form.save(False) user.is_active = False user.source = 'Register' user.save(True) site = get_current_site().domain sign = get_md5(get_md5(settings.SECRET_KEY + str(user.id))) if settings.DEBUG: site = '127.0.0.1:8000' path = reverse('account:result') url = "http://{site}{path}?type=validation&id={id}&sign={sign}".format( site=site, path=path, id=user.id, sign=sign) content = """ <p>Please click the link below to verify your email</p> <a href="{url}" rel="bookmark">{url}</a> Thank you again! <br /> If the link above cannot be opened, please copy this link to your browser. {url} """.format(url=url) send_email(emailto=[ user.email, ], title='Verify your email', content=content) url = reverse('accounts:result') + \ '?type=register&id=' + str(user.id) return HttpResponseRedirect(url) else: return self.render_to_response({'form': form})
def emailconfirm(request, id, sign): if not sign: return HttpResponseForbidden() if not get_md5(settings.SECRET_KEY + str(id) + settings.SECRET_KEY).upper() == sign.upper(): return HttpResponseForbidden() oauthuser = get_object_or_404(OAuthUser, pk=id) with transaction.atomic(): if oauthuser.author: author = get_user_model().objects.get(pk=oauthuser.author_id) else: result = get_user_model().objects.get_or_create( email=oauthuser.email) author = result[0] if result[1]: author.source = 'emailconfirm' author.username = oauthuser.nikename.strip( ) if oauthuser.nikename.strip( ) else "djangoblog" + datetime.datetime.now().strftime( '%y%m%d%I%M%S') author.save() oauthuser.author = author oauthuser.save() oauth_user_login_signal.send(sender=emailconfirm.__class__, id=oauthuser.id) login(request, author) site = get_current_site().domain content = ''' <p>Congratulations, you have successfully bound your mailbox, you can use {type} to directly log in to this website without a password. Welcome to continue to pay attention to this site, the address is</p> <a href="{url}" rel="bookmark">{url}</a> Thank you again! <br /> If the link above cannot be opened, please copy this link to your browser. {url} '''.format(type=oauthuser.type, url='http://' + site) send_email(emailto=[ oauthuser.email, ], title='Congratulations on your successful linking!', content=content) url = reverse('oauth:bindsuccess', kwargs={'oauthid': id}) url = url + '?type=success' return HttpResponseRedirect(url)
def emailconfirm(request, id, sign): print(1111111111111) if not sign: return HttpResponseForbidden() if not get_md5( settings.SECRET_KEY + str(id) + settings.SECRET_KEY).upper() == sign.upper(): return HttpResponseForbidden() oauthuser = get_object_or_404(OAuthUser, pk=id) with transaction.atomic(): if oauthuser.author: author = get_user_model().objects.get(pk=oauthuser.author_id) else: result = get_user_model().objects.get_or_create(email=oauthuser.email) author = result[0] if result[1]: author.source = 'emailconfirm' author.username = oauthuser.nikename.strip() if oauthuser.nikename.strip( ) else "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S') author.save() oauthuser.author = author oauthuser.save() oauth_user_login_signal.send( sender=emailconfirm.__class__, id=oauthuser.id) login(request, author) site = get_current_site().domain content = ''' <p>恭喜您,您已经成功绑定您的邮箱,您可以使用{type}来直接免密码登录本网站.欢迎您继续关注本站,地址是</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} '''.format(type=oauthuser.type, url='http://' + site) send_email(emailto=[oauthuser.email, ], title='恭喜您绑定成功!', content=content) url = reverse('oauth:bindsuccess', kwargs={ 'oauthid': id }) url = url + '?type=success' return HttpResponseRedirect(url)
def emailconfirm(request, id, sign): if not sign: return HttpResponseForbidden() if not get_md5(settings.SECRET_KEY + str(id) + settings.SECRET_KEY).upper() == sign.upper(): return HttpResponseForbidden() oauthuser = get_object_or_404(OAuthUser, pk=id) author = None if oauthuser.author: author = get_user_model().objects.get(pk=oauthuser.author_id) else: result = get_user_model().objects.get_or_create(email=oauthuser.email) author = result[0] if result[1]: author.username = oauthuser.nikename author.save() """ if oauthuser.email and author.email: login(request, author) return HttpResponseRedirect('/') """ oauthuser.author = author oauthuser.save() login(request, author) site = Site.objects.get_current().domain content = ''' <p>恭喜您,您已经成功绑定您的邮箱,您可以使用{type}来直接免密码登录本网站.欢迎您继续关注本站,地址是</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} '''.format(type=oauthuser.type, url='http://' + site) send_email(emailto=[ oauthuser.email, ], title='恭喜您绑定成功!', content=content) url = reverse('oauth:bindsuccess', kwargs={'oauthid': id}) url = url + '?type=success' return HttpResponseRedirect(url)
def emailconfirm(request, id, sign): if not sign: return HttpResponseForbidden() if not get_md5(settings.SECRET_KEY + str(id) + settings.SECRET_KEY).upper() == sign.upper(): return HttpResponseForbidden() oauthuser = get_object_or_404(OAuthUser, pk=id) author = None if oauthuser.author: author = get_user_model().objects.get(pk=oauthuser.author_id) else: result = get_user_model().objects.get_or_create(email=oauthuser.email) author = result[0] if result[1]: author.username = oauthuser.nikename author.save() """ if oauthuser.email and author.email: login(request, author) return HttpResponseRedirect('/') """ oauthuser.author = author oauthuser.save() login(request, author) site = Site.objects.get_current().domain content = ''' <p>恭喜您,您已经成功绑定您的邮箱,您可以使用{type}来直接免密码登录本网站.欢迎您继续关注本站,地址是</p> <a href="{url}" rel="bookmark">{url}</a> 再次感谢您! <br /> 如果上面链接无法打开,请将此链接复制至浏览器。 {url} '''.format(type=oauthuser.type, url='http://' + site) send_email(emailto=[oauthuser.email, ], title='恭喜您绑定成功!', content=content) url = reverse('oauth:bindsuccess', kwargs={ 'oauthid': id }) url = url + '?type=success' return HttpResponseRedirect(url)
def form_valid(self, form): email = form.cleaned_data['email'] oauthid = form.cleaned_data['oauthid'] oauthuser = get_object_or_404(OAuthUser, pk=oauthid) oauthuser.email = email oauthuser.save() sign = get_md5(settings.SECRET_KEY + str(oauthuser.id) + settings.SECRET_KEY) site = get_current_site().domain if settings.DEBUG: site = 'www.cxx1.com:80' path = reverse('oauth:email_confirm', kwargs={ 'id': oauthid, 'sign': sign }) url = "http://{site}{path}".format(site=site, path=path) content = """ <div style="background-color:#ECECEC; padding: 35px;"> <table cellpadding="0" align="center" style="width: 600px; margin: 0px auto; text-align: left; position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; font-size: 14px; font-family:微软雅黑, 黑体; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0px 0px 5px; border-collapse: collapse; background-position: initial initial; background-repeat: initial initial;background:#fff;"> <tbody> <tr> <th valign="middle" style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #42a3d3; background-color: #49bcff; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;"> <font face="微软雅黑" size="5" style="color: rgb(255, 255, 255); ">欢迎来到Cxx1.COM! </font> </th> </tr> <tr> <td> <div style="padding:25px 35px 40px; background-color:#fff;"> <h2 style="margin: 5px 0px; "> <font color="#333333" style="line-height: 20px; "> <font style="line-height: 22px; " size="4"> 亲爱的用户请绑定邮箱</font> </font> </h2> <p>首先感谢您加入本Cxx1站!请点击下方链接<br> <b> <a href="{url}" rel="bookmark">{url}</a></b><br> <b>如果没法打开请点击: {url} 并且复制到游览器</b> <p align="right"></p> <div style="width:700px;margin:0 auto;"> <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;"> <p>此为系统邮件,请勿回复<br> 请保管好您的邮箱,避免账号被他人盗用 </p> <p>©***</p> </div> </div> </div> </td> </tr> </tbody> </table> </div> """.format(url=url) send_email(emailto=[email, ], title='绑定您的电子邮箱', content=content) url = reverse('oauth:bindsuccess', kwargs={ 'oauthid': oauthid }) url = url + '?type=email' return HttpResponseRedirect(url)