I'm trying to adapt the example shown on http://www.django-rest-framework.org/ to Django 2.0, but I'm running into an error.
Firstly, I created a project using django-admin startproject rest_example. I've added 'rest_framework' to the INSTALLED_APPS list in settings.py and added the REST_FRAMEWORK variable:
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
]
}
Here is my adapted urls.py:
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'is_staff')
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
urlpatterns = [
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls'))
]
The problem is that when I python manage.py runserver and navigate to localhost:8000, I get a 404:
Similarly, if I navigate to localhost:8000/api-auth/, I get
Why is this not working?


