u'rest_framework' is not a registered namespace

1,047 views
Skip to first unread message

Daniel Sears

unread,
Feb 25, 2014, 4:58:20 PM2/25/14
to django-res...@googlegroups.com
I've gone through the tutorial and it's (mostly) working. So the following URLs work correctly:

https://example.com/rest_tutorial/snippets/
https://example.com/rest_tutorial/snippets/1/
https://example.com/rest_tutorial/users/
https://example.com/rest_tutorial/users/1/

But the following URLs generate a NoReverseMatch exception:

https://example.com/rest_tutorial/api-auth/login/
https://example.com/rest_tutorial/api-auth/logout/
Here's the exception value:

u'rest_framework' is not a registered namespace

It displays a portion of the login_base.html template file and highlights the URL in the form tag:

<form action="{% url 'rest_framework:login' %}" class=" form-inline" method="post">
I've run across this kind of error before and it's usually related to the lack of a namespace int the application's urls.py file. But in this case I'm including the namespace:

url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
My settings are also pretty basic:
REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES':       ('rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',),
    'PAGINATE_BY':                      10,
}

Secondly, the Api-Root button also generates a NoReverseMatch exception:

Reverse for 'user-list' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
 


Daniel Sears

unread,
Feb 28, 2014, 11:44:28 AM2/28/14
to django-res...@googlegroups.com
My problem was that in part 4 of the tutorial I added the url pattern to the app-level urls.py instead of the project-level urls.py:

urlpatterns += patterns('',

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

                               namespace='rest_framework')),
)

I submitted a (small) doc pull request.

--Dan

Reply all
Reply to author
Forward
0 new messages