On 10/18/06, Stefán Freyr Stefánsson <[EMAIL PROTECTED]> wrote: > Hello. > > I'm creating a web application that monitors information on distributed > computers. This information (which is numerical; the sizes of queues running > in a process on each of the computers) is put into a single database table > with a column identifying which computer that row is referring to. So the > table is on the form (computer_id, queue1_size, queue2_size, queue3_size) > roughly. > > I've created a web page that displays a bar chart with this information. > Each computer gets a "group" of three bars with each bar representing each > of the queue size. In addition to the queue sizes for each computer I also > want to display some general information not specific to any one of the > computers (such as the total number of processes running etc). > > So now (finally) to my problem. I'm trying to get this bar chart to update > with AJAX so that the whole page isn't refreshed every other second. For > this I was hoping to use Django's JSON serialization but this is where I'm > running into trouble. > > I have two model classes. One representing a row in the aforementioned table > and another one that represents the database table containing the "summary" > information. When the web page updates its info (does the AJAX call) I would > like to retrieve all information that I need in a single call and update 1) > the summary information 2) the queue status for all the workers displayed as > bars on the web page. > > Currently I only seem to be able to serialize the summary information (which > is just one row) or a list of the queue information. What I'd like to be > able to do is to somehow serialize: > 1. a single row from the summary information table > 2. a list of queue information (each item representing the latest > information for each computer). > in a single "datastructure" to be sent as a JSON string over to the > JavaScript client. > > So, if anybody can tell me whether it's possible to create a "custom" > datastructure and serialize that over the wire as a JSON string, I'd > appreciate it very much.
Within your view, create your "custom" datastructure in python. When you have everything you want, (but not before) pass that to the serializer. -- ---- Waylan Limberg [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---