Yes and I am stating that a ValueQuerySet seems related enough to QuerySet that in Django default behavior should allow them to work with Django serializers, and I'm not the only one to have assumed it would! Using Django serializes you'll find that a ValueQuerySet is missing attribute _meta when it goes to walk the model class def. Well the reality is in AJAX situations we often don't want to send the whole model and so being able to serialize a ValueQuerySet is a very useful feature that Django is lacking for simplifying the query:
Well, we also have: def enrollment_assignments(request, enrollment_id): """ AJAX call to get list of assignments for enrollment_id. """ if request.is_ajax(): # Fetch Assignment List enrollment = Enrollment.objects.get(id__exact=enrollment_id) assignments = Assignment.objects.values('id', 'name').filter(course=enrollment.course).order_by('name') payload = json.dumps([a for a in assignments]) else: payload = "Sorry, this URL is for AJAX calls only." return HttpResponse(payload, content_type = 'application/javascript; charset=utf8') # End Def Also I must have filled out the Django EuroCon 2011 Amsterdam form 4 or 5 times and I still haven't received any E-mails about this. I probably should have stayed with RAILS 4 years ago, but oh no Python and Django Reinhardt ..... Well and Django has really fixed many of my initial concerns, I really want to go, there is a bunch of stuff I missed in Amsterdam the last time I went in 2007. I would also like to give a presentation of django-classcomm Http://classcomm.googlecode.com/ and http://classcomm.net/ as well as working on the Django development sprint following the conference. -Matteius On Feb 13, 8:11 pm, Russell Keith-Magee <russ...@keith-magee.com> wrote: > On Mon, Feb 14, 2011 at 9:55 AM, Matteius <matte...@gmail.com> wrote: > > I want to optimize my json call and protect data by doing something > > like: > > > assignments = Assignment.objects.values('id', > > 'name').filter(course=enrollment.course) > > payload = serializers.serialize("json", assignments, > > ensure_ascii=False) > > > But my experience and others have been: > > > (' dict object has no attribute __meta'). > > > The only option I see is to manually encode a json string and bypass > > the serialization? > > This question is very close to being a "How To" question. > Django-developers is for discussing the development of Django itself. > If you want to ask how to do something, you should ask on > django-users. > > However -- just in case this was a misphrased request for discussion > of a feature proposal: Django's serializers are not universal > serializers. They are specifically for serializing full querysets -- > i.e., collections of full objects. If you want to serialize other > structures, you need to use simplejson.dumps natively. > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.