Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.10 urls deprecation

have some deprecation warning. Here is the problem:

RemovedInDjango110Warning: Support for string view arguments to url()
is deprecated and will be removed in Django 1.10 
(got django.views.static.serve). Pass the callable instead.
'document_root': settings.MEDIA_ROOT,

Here is the urls:

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.MEDIA_ROOT,
        }),
    url(r'^post/(\d+)$', post),
    url(r'^(\w+)$', category),
    url(r'^$', category),
]

How to fix it? Thanks for your time.

like image 681
KaronatoR Avatar asked Jan 11 '16 17:01

KaronatoR


1 Answers

Replace function paths in string with actual view functions. For instance:

from django.views.static import serve
...
url(r'^media/(?P<path>.*)$', serve, {
        'document_root': settings.MEDIA_ROOT,
    }),
like image 111
Lorenzo Peña Avatar answered Nov 29 '22 00:11

Lorenzo Peña