I could suggest you creating the json manually (this is bad if you plan to scale you app) or make the dictionary with the necessary data and then serialize it. i.e users = [{'user': l.user.name, 'status': l.status} for l in ActiveList.objects.all()] Also it would be probably better idea to add the status attribute to the User model itself (by adding the profile information, see Django Topics; with some 'O' for Offline) and changing the queryset to User.objects.exclude(status='O')
On Jul 11, 10:43 pm, Oleg Oltar <oltarase...@gmail.com> wrote: > Hi! > > I am trying to implement something like a jubber web application, using > django and flex > > The server code should send a list of users who's online. Here's how I > defined a model > > class ActiveList(models.Model): > > STATUS_CHOISES = ( > (u'F', u'free'), > (u'B', u'busy'), > ) > user = models.ForeignKey(User, unique=True) > status = models.CharField(max_length=2, choices = STATUS_CHOISES) > > The view look like this > > def getActiveUsers(request): > activeList = ActiveList.objects.all() > > data = serializers.serialize("json", activeList, fields = (u'user', > 'status')) > return HttpResponse(data, mimetype='application/json') > > The question, how can I return username of user in fields. I want the JSON > response to contain value user.username instead of id of user oject > > Thanks, > Oleg --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---