Reverse for 'activate' with keyword arguments '{'uidb64': b'Mw', 'token': '4vb-698f794fd74543e1258f'}' not found. 1 pattern(s) tried: ['activate/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$']模板/account_activation_email.html
{% autoescape off %}
Hi {{ user.username }},
Please click on the link below to confirm your registration:
http://{{ domain }}{% url 'activate' uidb64=uid token=token %}
{% endautoescape %}在我的本地主机url上,它似乎运行得很好;但是当它在heroku被谴责的时候。它会抛出这个错误。
views.py
def activate(request, uidb64, token):
try:
uid = force_text(urlsafe_base64_decode(uidb64))
user = User.objects.get(pk=uid)
except (TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.profile.email_confirmed = True
user.save()
login(request, user)
return redirect('home')
else:
return render(request, 'account_activation_invalid.html')urls.py
url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
core_views.activate, name='activate'),发布于 2018-04-13 07:01:29
'uidb64': b'Mw'这是一个byte code,但django需要一个string,
因此,在view中,您要从其中发送uid
做decode,uid.decode('utf-8')
然后将其发送到模板。
https://stackoverflow.com/questions/49810996
复制相似问题