My file urls.py :
#home/urls.py
from django.urls import path, re_path
from home.views import homePageView
urlpatterns = [
path('',homePageView.as_view(),name='home'),
re_path('activate/(?P<code_>[a-zA-Z0-9]{15})/(?P<email_>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$', homePageView.activate, name='activate')
]
Method activate in views.py :
class homePageView(TemplateView):
template_name = 'index.html'
def activate(self, request, *args, **kwargs):
try:
email_ = kwargs['email_']
code_ = kwargs['code_']
user = Usuario.objects.get(email=email_,activated_code=code_)
code = user.activated_code
if (not user.activated) and code == code_:
user.activated = True
user.save()
messages.success(request, 'User activated successfully')
else:
messages.error(request,'Error activating user, please, use the contact form to contact us')
except Usuario.DoesNotExist:
messages.error(request,'Error activating user, please, use the contact form to contact us')
return redirect('home')
when entering an url like this:
http://127.0.0.1:8000/activate/aE8w3fqEsoLMykQ/[email protected]/
throws me the following error:
activate () missing 1 required positional argument: 'request'