BUG!!!======>django实战,djangoframework : type object 'URLObject' has no attribute 'parse'; u'djangorestframework' is not a registered namespace
在学习django的过程当中,跟着学习了一篇CSDN内心求法的文章http://blog.csdn.net/thinkinside/article/details/7236807,在这个部分中,需要安装一个django的可选的REST framework,选用了djangoframework。废话不多说,按照步骤会出现这个问题:
AttributeError at /API/cart/items type object 'URLObject' has no attribute 'parse' Request Method: GET Request URL: http://127.0.0.1:8000/API/cart/items Django Version: .4 Exception Type: AttributeError Exception Value: type object 'URLObject' has no attribute 'parse' Error during template rendering In template C:\Python27\lib\site-packages\djangorestframework-0.3.2-py2.7.egg\djangorestframework\templates\renderer.html, error at line 68 type object 'URLObject' has no attribute 'parse'
在网上找了许多解决办法,最后发现原文作者的django版本是基于1.3的,但是现在大部分用的1.4的版本,所以有可能问题是djangoframework的版本不够,重新将其卸载掉,然后下了一个0.4.0的版本,安装以后,旧的问题没有了,又出现了一下的问题:
u'djangorestframwork' is not a registered namespace
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']
我找到了这篇文章
django 1.4 = u'djangorestframwork' is not a registered namespace
也提问了这个问题,重新安装了找到了解决的办法如下:
Login / Logout Django REST framework includes login and logout views that are needed if you’re using the self-documenting API. Make sure you include the following in your urlconf: from django.conf.urls.defaults import patterns, url urlpatterns = patterns('', ... url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework')) )
方法参考:http://django-rest-framework.readthedocs.org/en/latest/howto/setup.html#setup
“某度”空间 http://hi.baidu.com/new/wenjiashe521
cnblogs空间 http://www.cnblogs.com/wenjiashe521/