A
A
Azamat2016-12-10 10:26:42
Django
Azamat, 2016-12-10 10:26:42

What to use instead of patterns in django 1.10?

Hello, in previous versions of janga, for statics, you had to add to urls.py

from django.conf.urls import patterns

if settings.DEBUG:
  urlpatterns += patterns('',
  (r'^static/(?P<path>.*)$', 'django.views.static.serve',
  {'document_root': settings.STATIC_ROOT}),
  )

But in django 1.10, as I understand it, patterns were removed from django.conf.urls.
I can't figure out what to replace it with. Previously, this helped to collect static from css and js files.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2016-12-10
Sharafiev @whoisazamat

Patterns are now regular lists

urlpatterns = [
  url(r'^$', some_view),
]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

A
Artyom Innokentiev, 2016-12-10
@artinnok

Read here and never do this:
if settings.DEBUG:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question