encode / django-rest-framework

Web APIs for Django. 🎸
https://www.django-rest-framework.org
Other
28.45k stars 6.84k forks source link

django 1.4 = u'djangorestframwork' is not a registered namespace #217

Closed ghost closed 12 years ago

ghost commented 12 years ago

I recently upgraded to django 1.4 as per client request.

I thought everything was working, but it appears not.

Any url request, spits out the error below:

Error during template rendering

In template /usr/lib/python2.6/site-packages/djangorestframework-0.4.0_dev-py2.6.egg/djangorestframework/templates/djangorestframework/base.html, error at line 26

NoReverseMatch at /mobile/getUserProfile/
u'djangorestframework' is not a registered namespace
Request Method: GET
Request URL:    http://quadstreaker.stage.pugetworks.com/mobile/getUserProfile/
Django Version: 1.4
Exception Type: NoReverseMatch
Exception Value:    
u'djangorestframework' is not a registered namespace
Exception Location: /usr/lib/python2.6/site-packages/django/template/defaulttags.py in render, line 424
Python Executable:  /usr/bin/python
Python Version: 2.6.6
Python Path:    
['/home/django/quadstreaker',
 '/usr/lib/python2.6/site-packages/boto-2.0rc1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/google_api_python_client-1.0beta2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/python_gflags-1.6-py2.6.egg',
 '/usr/lib/python2.6/site-packages/oauth2-1.5.170-py2.6.egg',
 '/usr/lib/python2.6/site-packages/httplib2-0.7.1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/pybing-0.1dev_r34-py2.6.egg',
 '/usr/lib/python2.6/site-packages/recaptcha_client-1.0.5-py2.6.egg',
 '/usr/lib/python2.6/site-packages/APNSWrapper-0.6.1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/docutils-0.8.1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/bitly_api-0.1.c-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_tracking-0.4.0-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_simple_autocomplete-0.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/distribute-0.6.27-py2.6.egg',
 '/usr/lib/python2.6/site-packages/URLObject-2.0.1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/djangorestframework-0.4.0_dev-py2.6.egg',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib64/python2.6/site-packages/PIL',
 '/usr/lib/python2.6/site-packages']
Server time:    Tue, 12 Jun 2012 14:16:05 -0700
ghost commented 12 years ago

This is the latest git version 0.4.0_dev

ghost commented 12 years ago

I'm running 0.4.0 because it appeared that 0.3.2 was not compatible with django 1.4...

tomchristie commented 12 years ago

It sounds like you have the login/logout views included in your urlconf, without the 'djangorestframework' namespace set. Eg in your top level urlconf, you might have a line like this, but without the namespace='djangorestframework' bit?...

url(r'^restframework/', include('djangorestframework.urls', namespace='djangorestframework')),
ghost commented 12 years ago

I didn't know djangorestframework provided login/logout views or any other built-in urls. (until this issue occurred)

I have the following in an app/urls.py file:

( r'^login/$', LoginRESTView.as_view(), ),
( r'^logout/$', LogoutRESTView.as_view(),  ),

and in another app/urls.py file: ( r'^login/$', 'django.contrib.auth.views.logout', { 'template_name': 'login.html', 'next_page': '/' }, 'login' ), ( r'^logout/$', 'django.contrib.auth.views.logout', { 'template_name': 'logout.html', 'next_page': '/' }, 'logout' ),

Could either of these be causing the django to inherit the djangorestframework login/logout functions?

tomchristie commented 12 years ago

This is documented correctly on readthedocs, but the django-rest-framework.org version is out of date (Urg!):

Take a look at http://django-rest-framework.readthedocs.org/en/latest/howto/setup.html#setup

You need to include the restframework views, so that the API browser has a login and logout view that it can use.

On 13 June 2012 16:42, Bill Levering < reply@reply.github.com

wrote:

I didn't know djangorestframework provided login/logout views or any other built-in urls. (until this issue occurred)

I have the following in an app/urls.py file:

( r'^login/$', LoginRESTView.as_view(), ), ( r'^logout/$', LogoutRESTView.as_view(), ),

and in another app/urls.py file: ( r'^login/$', 'django.contrib.auth.views.logout', { 'template_name': 'login.html', 'next_page': '/' }, 'login' ), ( r'^logout/$', 'django.contrib.auth.views.logout', { 'template_name': 'logout.html', 'next_page': '/' }, 'logout' ),

Could either of these be causing the django to inherit the djangorestframework login/logout functions?


Reply to this email directly or view it on GitHub:

https://github.com/tomchristie/django-rest-framework/issues/217#issuecomment-6304620

ghost commented 12 years ago

Yes, I've been reading the out of date site... and this appears to only be an issue in 0.4.

Is the readthedocs site for the dev version and the other for 0.3? Maybe that could be made more clear.

tomchristie commented 12 years ago

Is the readthedocs site for the dev version and the other for 0.3

Nope, it's just crud and out of date. I'll fix it later this week.