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 =
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 =
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,
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 =
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
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
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
7 matches
Mail list logo