Registration using e-mail, Django 2.0

后端 未结 1 939
滥情空心
滥情空心 2021-01-26 07:41

I\'m just a beginner, so i got some questions making my first project. I\'ve got code in views:

def signup(request):
if request.method == \'POST\':
    form = Si         


        
相关标签:
1条回答
  • 2021-01-26 07:59

    You can't use regexes like [0-9A-Za-z_\-]+ when you use path(). If you want to use regexes, then use re_path (which works the same as url() from older versions of Django).

    When you use path(), you can use one of the built-in path converters. You can't use <int:uidb64>, because uidb can contain A-Za-z, hyphens, and underscores, not just digits.

    For your uidb64 and token, I think slug is the most suitable of the path converters included in Django.

    path('activate/<slug:uidb64>/<slug:token>/', views.activate, name='activate'),
    

    This will match slugs and tokens which your regex wouldn't allow, but this isn't a problem as long as your check_token method returns False for these invalid values and does not raise an error.

    0 讨论(0)
提交回复
热议问题