Django Tastypie:超过最大递归深度
我正在学习django tastypie的教程,在连接完资源后,我去了Django Tastypie:超过最大递归深度,django,tastypie,Django,Tastypie,我正在学习django tastypie的教程,在连接完资源后,我去了http://localhost:8000/api/entry/?format=json,我在JSON中遇到了以下错误: {"error_message": "maximum recursion depth exceeded", "traceback": "Traceback (most recent call last):\n\n File \"C:\\Python27\\lib\\site-packages\\djang
http://localhost:8000/api/entry/?format=json
,我在JSON中遇到了以下错误:
{"error_message": "maximum recursion depth exceeded", "traceback": "Traceback (most recent call last):\n\n File \"C:\\Python27\\lib\\site-packages\\django_tastypie-0.9.14-py2.7.egg\\tastypie\\resources.py\", line 202, in wrapper\n response = callback(request, *args, **kwargs)\n\n\
models.py:
from tastypie.utils.timezone import now
from django.contrib.auth.models import User
from django.db import models
from django.template.defaultfilters import slugify
class Entry(models.Model):
user = models.ForeignKey(User)
pub_date = models.DateTimeField(default=now)
title = models.CharField(max_length=200)
slug = models.SlugField()
body = models.TextField()
def __unicode__(self):
return self.title
def save(self, *args, **kwargs):
# For automatic slug generation.
if not self.slug:
self.slug = slugify(self.title)[:50]
return super(Entry, self).save(*args, **kwargs)
api.py:
from tastypie.resources import ModelResource
from myapp.models import Entry
class EntryResource(ModelResource):
class Meta:
queryset = Entry.objects.all()
resource_name = 'entry'
请尝试取消注释“(r'^blog/”,include('myapp.url'),将其置于URL模式下,然后再次运行应用程序。只需注释掉“(r'^blog/”,include('myapp.url')”可以在URL.py中的urlpatterns下找到,然后重新运行应用程序。有一些代码要共享吗?例如,您可以发布模型和资源吗?这可能会有帮助;-)我正在按照