Skip to content

Update tutorial to Django 2.0 url routing syntax #5963

Closed
@chrisshyi

Description

@chrisshyi

Hello everyone, newcomer to DRF here. I just started learning how to use DRF yesterday and noticed the tutorials (part 1 at least, not sure about the other parts) have not been updated to use the latest Django 2.0 URL routing syntax.

For example,

from django.conf.urls import url
from snippets import views

urlpatterns = [
    url(r'^snippets/$', views.snippet_list),
    url(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail),
]

should be

from django.urls import re_path
from snippets import views

urlpatterns = [
    re_path(r'^snippets/$', views.snippet_list),
    re_path(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail),
]

Alternatively, the path() function can be used. I'd be more than happy to help with updating the tutorials but I'm not sure how (never contributed to open source before). I assume I can start by cloning the repo, make the changes in the tutorial markdown files, and then make a pull request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions