Tuesday, August 31, 2010

Doing ajax with django models serialization: jquery part

We have finished(somewhat) with our json source, now we can do ajax. With the help of jquery, we can use the data source to create something interactive. One of the key ingredient is the jquery ajax function, there is a few such as, $.post, $.get, $.getJSON etc. Here I use $.getJSON, because

Lets start with load data to a table from a json source last post. 
Loading data into table alone is not that exciting, and you can do that using django templates, but this shows a example of loading data using json

You can get the example project here
http://github.com/sweemeng/Sweemeng-django-example/tree/master/djangoajax/

Tuesday, August 17, 2010

Software Freedom Day @ KL

Another year, another Software Freedom Day

I have registered a team for sfdkl, and the page is at https://sites.google.com/site/sfdkl2010/

It will be held on 19 Sept 2010, a Sunday, at hackerspacekl

And with the help of hackerspacekl, i borrowed the space for software freedom day. Which is cool, because there is a few place to eat there.

What we plan to do

  1. Have a gathering of foss geeks on the day itself, 
  2. Someone will give a talk on the day itself
  3. Frag fest aka Lan party of foss game, in the end of the day, this is the only event that is confirmed
  4. t will also be held with a unix-g33kz session which  is part of hackerspacekl own project, while this is payed project, the rest of the event is not

What we need now, speaker, well attendee. And last but not least, participant for our Frag Fest(we even got a switch ready),
you can register on the google site page, add your talk there as well.
https://sites.google.com/site/sfdkl2010/

Friday, July 09, 2010

Doing ajax with django models serialization: json part

Finally a technical post after a long while, here goes

On my new job, the site requires a crazy level of interactivity, probably for the wrong reason, but lets not go there now.

Along the way, we decide to use a mix of javascript, and html, with a help of json. Thats is where, django serialization comes in. What it does is, it serialize a django queryset into xml or json. If i need to use that to generate json for django queryset, because simplejson cannot do it, not directly.

To output a queryset to json is pretty easy.


from django.core import serializers
data = serializers.serialize('json', queryset)


where queryset your djangoqueryset


in a sample database, in a called addressbook





to play around with the django shell, assume that data already there


>>> from django.core import serializers
>>> from addressbook.models import Contact
>>> serializers.serialize('json', Contact.objects.all())
[{"pk": 1, "model": "addressbook.contacts", "fields": {"phone": "012345678", "post_code": "68100", "name": "sweemeng", "address": "somewhere in selayang"}}]


To make it useful for my purpose to use in a javascript, i need to put this into a views, point your urls.py to the views, and run the server, and point your browser to it, you should able to see a json output





But here is the catch, one, this is strictly only for serializing django queryset, you can still use simplejson for other type of data. two it seems that django serializer don't serialize a single model instance.


Next post, using it with a jquery

more information on django serialization


Sunday, June 27, 2010

A day in unix-g33k @ #hackerspacekl

One of the big project of the year in hackerspacekl is unix-g33k. the goal of unix-g33k is to expose geek/geekette and non-geek alike on unix, particularly on freebsd. The workshop done in Suresh. And organize with the help of hackerspacekl particularly Sniifit and Brian Ritchie,.

The workshop covers basic OS concept for the first day, with Suresh prepared a VM running freebsd that allow us to access it via SSH for playing around. Today session itself is enlightening, while it is also serve as a reminder of the OS course i took in uni, with some extra stuff that Suresh give that involved that stuff involve the real world.

The attendee is from various background, most from IT, some runs their own business. And doing a session on a floor is a real interesting experience, kudos for the organizer for preparing more plug points for the participant, and the session is not formal, and that is always a good thing.

After the session just hang around in a coffee shop nearby. And discuss all geeky stuff.

What to look forward to for the next unix-g33k session? It involve more practical hands on freebsd. More deep stuff.

BTW the photo is here, thanks to CLchow,


**ps, no pics again, no camera sorry.

Sunday, June 06, 2010

Open Source Conference by osdc.my

MOSC 2010 is a open source conf organized by osdc.my. It will be held in  29th June to 1st June 2010) Like last year it will be held in Berjaya Time Square. Which is cool, because it is very accessible via public transport.

This year conference will have participation from a few key open source player, Red Hat and Novell is there, also a representative from the Linux Foundation will be on the conference as well. The community is represented by ubuntu.my, joomla, OWASP, wordpress, and a few others. 

This year talk have more variety than last year, it covers talk from Cloud Computing, to Security, to Uses in academics. There will be a few mini events within mosc 2010, such as Milking The Cloud competition by Microsoft, and Gecko Moving Forward by Novell. Of course there will be many community events from joomla, and wordpress among others. And not to mention show case a foss project in malaysia. 

This year conference will be a interesting conference to look forward to. And this year, I will wear a difference hat in the conference. 

Btw Check the link for more information

Malaysia Open Source Conference


Malaysia Open Source
Conference 2010 Organize By OSDC.my