I am working on Django and I am getting error while run code like this :
Using the URLconf defined in mysite.urls, Django tried these URL
patterns, in this order:
^admin/
^employees/
The empty path didn't match any of these.
here is my urls.py :
from django.conf.urls import url
from django.contrib import admin
from webapp import views
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^employees/', views.employeeList.as_view()),
]
here is vies.py:
class employeeList(APIView):
def get(self, request):
employees1 = employees.objects.all()
serializer = employeesSerializer(employees1, many=True)
return Response(serializer.data)
def post(self):
pass
and Settings.py :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'webapp'
]
try changing url from
url(r'^employees/', views.employeeList.as_view())
to
url(r'^employees/$', views.employeeList.as_view(), name='employees' )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.