Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django name patterns is not defined in ulrs.py

I am trying to set up a Django app, but everytime I try to run it i get the following error message: NameError: name 'patterns' is not defined

I do not understand what is wrong with my urls.py file, here is a copy of it:

from django.contrib import admin
from rest_framework import routers
from SecMeRe import views

router = routers.DefaultRouter()
#makes sure that the API endpoints work
router.register(r'api/SecMeRe', views.PatientViewSet)
admin.autodiscover()

urlpatterns = patterns(
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include(router.urls)),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)
like image 819
0xtuytuy Avatar asked Nov 27 '16 22:11

0xtuytuy


1 Answers

Use this:

from django.conf.urls import url, include
urlpatterns = [
  url(r'^admin/', include(admin.site.urls)),
  url(r'^', include(router.urls)),
  url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))]
like image 82
Zagorodniy Olexiy Avatar answered Sep 21 '22 15:09

Zagorodniy Olexiy