How to capture URL parameters in request.GET with Python Django?

To capture URL parameters in request.GET with Python Django, we can add a view to match a URL pattern that takes a URL parameter.

Then we can get the parameter value from the view function’s parameter.

For instance, we write

(r'^user/(?P<username>w{0,50})/$', views.profile_page,),

to add a view that matches the r'^user/(?P<username>w{0,50})/$' route.

Then in our view file, we add a view with

def profile_page(request, username):
    # ...

to get the username URL parameter value from username.