我开始搞乱Tastypie并遇到一个问题,我的db中的任何对象的GET请求有时会成功返回该对象,而其他时候会返回500错误,其中包含“包含的urlconf不会有任何模式“。
下面我通过CURL包含了两个查询的结果。一个返回对象,紧接着后面的那个返回500错误(我将500个结果缩短)
mrichardson@box [16:40] :~$ curl http://localhost:10000/app/app/bbaa8eba-5065-405f-8c65-abfdb05b5a7f/?format=json
{"code": "", "created": "2013-11-29T22:26:39", "id": "bbaa8eba-5065-405f-8c65-abfdb05b5a7f", "key": ">^GlK;8%UBpB!x8!jC][[cV%6", "modified": "2013-11-29T22:26:39", "name": "", "resource_uri": "/app/app/bbaa8eba-5065-405f-8c65-abfdb05b5a7f/"}
mrichardson@box [16:40] :~$ curl http://localhost:10000/app/app/bbaa8eba-5065-405f-8c65-abfdb05b5a7f/?format=json
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE">
<title>ImproperlyConfigured at /app/app/bbaa8eba-5065-405f-8c65-abfdb05b5a7f/</title>
我的网址配置如下:
from django.conf.urls import patterns, include, url
from app.resources import app_resource
appres = app_resource()
urlpatterns = patterns('',
url(r'^app/', include(appres.urls)),
)
app.resources看起来像这样:
from tastypie.resources import ModelResource
from app.models import app
class app_resource(ModelResource):
class Meta:
queryset = app.objects.all()
resource_name = 'app'
当我请求任何东西时,问题就出现了,而不仅仅是特定的对象。例如,如果我只是想获得app / app实体列表。
mrichardson@box [16:56] :~$ curl -X GET -I http://localhost:10000/app/app/?format=json
HTTP/1.1 500 INTERNAL SERVER ERROR
Date: Sat, 30 Nov 2013 05:56:43 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
mrichardson@box [16:56] :~$ curl -X GET -I http://localhost:10000/app/app/?format=json
HTTP/1.1 200 OK
Date: Sat, 30 Nov 2013 05:56:44 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
Transfer-Encoding: chunked
Content-Type: application/json
有人可以就可能导致此行为的原因向我提出任何建议吗?