2013-04-11 105 views
0

我下面從Django的tastypie教程後,掛鉤的資源(S),我去http://localhost:8000/api/entry/?format=json,我在JSON得到這個錯誤:Django的Tastypie:最大遞歸深度超過

{"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\ 

模型。潘岳:

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' 
+0

得到了一些代碼你想分享嗎? – 2013-04-11 09:00:27

+0

例如,你可以發佈你的模型和資源?它可以幫助;-) – Ponytech 2013-04-11 09:03:10

+0

我從http://django-tastypie.readthedocs.org/en/latest/tutorial下面的教程。 html#creating-resources – Alvin 2013-04-11 09:04:54

回答

0

嘗試取消註釋 「(R '^博客/',包括( 'myapp.urls')」 作爲Y你可以放在urlpatterns下,然後再運行你的應用程序。

0

只是註釋掉「(R‘^博客/’,包括(‘myapp.urls’)」它可以在URL模式在urls.py中找到,然後重新運行你的應用程序。