0

I still don't understand how URLs work in Django 1.x very well, and am having trouble doing so in Django 2.x.

Could someone help with with how to translate this to Django 2.x?

urlpatterns = [
    url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
    views.activate, name='activate'),
]
FlipperPA
  • 13,607
  • 4
  • 39
  • 71
CAB
  • 125
  • 4
  • 12

1 Answers1

1

You can replace url() with re_path() (regular expression path) in Django 2.0. So you'd do this instead:

from django.urls import re_path

urlpatterns = [
    re_path(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', views.activate, name='activate'),
]

The new path() function is useful for more simple URLs than this one.

FlipperPA
  • 13,607
  • 4
  • 39
  • 71