0

我正在遵循 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\\django_tastypie-0.9.14-py2.7.egg\\tastypie\\resources.py\", line 202, in wrapper\n    response = callback(request, *args, **kwargs)\n\n\

模型.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'
4

2 回答 2

0

尝试取消注释 "(r'^blog/', include('myapp.urls')" 您放在 urlpatterns 下,然后再次运行您的应用程序。

于 2013-06-27T10:28:21.933 回答
0

只需注释掉可以在 urls.py 中的 urlpatterns 下找到的“(r'^blog/', include('myapp.urls')”,然后重新运行您的应用程序。

于 2013-07-16T09:25:05.117 回答