Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-04-02 Thread Legioneer
Found a solution. It works when add fields parameter to serialize, but only when without parent field: e.g. serializers.serialize("json", c, fields='name,rank') works perfect, while serializers.serialize("json", c, fields='name,rank,parent') raises DoesNotExist exception where c =

Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-04-02 Thread Legioneer
yes. in admin there are no problems with it. On Apr 2, 4:40 am, 1234 <[EMAIL PROTECTED]> wrote: > Is this model work on in admin? > > 2008/4/1, Legioneer <[EMAIL PROTECTED]>: > > > > > My data model is very similar to your: > > > class Category(models.Model): > > name =

Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-04-01 Thread Legioneer
My data model is very similar to your: class Category(models.Model): name = models.CharField(max_length=64) descr = models.CharField(max_length=255, blank=True) rank = models.PositiveIntegerField(default=10) parent = models.ForeignKey('self', null=True,

Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-04-01 Thread 1234
this is my example class Type(models.Model): type = models.CharField('分类名称',maxlength=50,core=True) path = models.CharField('url地址',maxlength=250,blank=True,editable=False) typename = models.CharField('分类名称',maxlength=200,editable=False) parent =

Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-04-01 Thread Legioneer
Thank you, Michael. Tried several combinations but it doesn't work either. 1. First I tried to use Category.objects.all(): c = Category.objects.all() serializers.serialize("json", c) and got the same error. 2. Then tried to init some variable with s[:5] and the result didn't change. 3. When

Re: JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-03-31 Thread Michael
Your error is actually coming from the fact that you are not getting any results from your filter query. The reason that the error is appearing on the second line of your script is because filter is a lazy call and isn't really made until you ask it to return objects in this bit: s[:5]. Change

JSON serializers.serialize raises DoesNotExist on recursive data structures

2008-03-31 Thread Legioneer
Hi All, I'm trying to serialize recursive model (a category which refers to itself) and get a 'DoesNotExist: Category matching query does not exist', while other models work fine. Does anyone know a clue for this? I'm doing like this: from django.core import serializers; from newproject.models