You could use a objects.values(...) which return a dictionary if I remember
correctly, and then simplejson.dumps...
Ben

On 18/11/2007, Bryan L. Fordham <[EMAIL PROTECTED]> wrote:
>
>
> So, say I have a model something like this:
>
> class Bar(models.Model):
>     user = models.ForeignKey(User)
>     name = models.CharField(maxlength=50)
>     description = models.TextField()
>
> where user is tied to a django.contrib.auth.models.User entity. When I
> serialize this to json, I get:
> [{"pk": "1", "model": "foo.bar", "fields": {"description": "", "user":
> 1, "name": "Phone"}}]
>
> Which is fine, but I need both the username and user id on the front
> end. Is there a simple way to get this info all in one shot that I'm
> just missing?
>
> Ideally, it would return something like: ..."user":
> {"username":"bfordham", "pk":1}...
>
> I'm using the django-rest-interface, if that makes a difference one way
> or the other.
>
> Thanks
> --B
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to