[Solved]-U'rest_framework' is not a registered namespace


The issue is with your namespaces. Specifically, you are using a nested namespace and Django REST framework was not expecting that to be the case.

The tutorial for logging into the browsable API recommends the following snippet of code for your API urls

# The API URLs are now determined automatically by the router.
# Additionally, we include the login URLs for the browsable API.
urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))

So your login urls will be located at /api-auth/ and have a namespace of rest_framework, so the don’t interfere with existing url patterns. This tutorial assumes that you are in the root urlconf when you are putting in the patterns, or at least that you are not using extra namespaces. This is because the url rest_framework:login is used to generate the login page for the browsable API, so the namespace must be rest_framework.

In your case, you are registering the urls under api, so the view name is actually api:rest_framework:login. The error that you are getting

u’rest_framework’ is not a registered namespace

Is because the rest_framework namespace is not a root namespace. You can fix this by moving the urlpattern outside of api/urls.py, or overriding the browsable API templates.


Try adding the line url(r'^api-auth/', include('rest_framework.urls',namespace='rest_framework')), to your main urls.py or change the namespace of api/ to rest_framework instead (and remove it from the other url)…


In my case I put this line:
path('api-auth/', include('rest_framework.urls')),
inside my app level urls.py when you should put it in your project level urls.py.

Hope it helps 🙂


If you are not using the namespace from api you can simply remove the namespace from your route

url(r'^api/', include('api.urls', namespace='api'))

I have the same issue and for me works because I don’t use the namespace from api nowhere



Put this line in your URL section:

url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),

Leave a comment