Q:

Updating protected serve url path with patterns for django 1.11

How do you use this code in the current (1.11) version of Django?  The code below uses patterns module but as I googled it was removed in 1.10. 
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.views.static import serve
from django.conf import settings

@login_required
def protected_serve(request, path, document_root=None, show_indexes=False):
    return serve(request, path, document_root, show_indexes)

urlpatterns = patterns('',
    url(r'^%s(?P<path>.*)$' % settings. MEDIA_URL[1:], protected_serve, {'document_root': settings. MEDIA_ROOT}),
)

Here's the source tutorial link 

A:

In Django 1.8+, urlpatterns should be a list (release notes).  Remove the patterns import as well. 
from django.conf.urls import include, url

urlpatterns = [
    url(r'^%s(?P<path>.*)$' % settings. MEDIA_URL[1:], protected_serve, {'document_root': settings. MEDIA_ROOT}),
]

