zennn
zennn

Reputation: 125

NoReverseMatch at /signup/

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})/$']

templates/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 %}

It seems to be working fine on my localhost url; but when it's deplyed in heroku. it throws this error.

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'),

Upvotes: 1

Views: 1118

Answers (1)

Exprator
Exprator

Reputation: 27533

'uidb64': b'Mw'

this is a byte code, but django expects a string,

so in the view from where you are sending the uid

do a decode, uid.decode('utf-8')

then send it to the template

Upvotes: 1

Related Questions