I've been using Django for a few weeks now and I have to say, despite my general hatred of frameworks, I'm quite impressed with it. It is very fast to get up and going, the ORM works pretty well. New forms are really, really good.
I don't like learning new template languages though... so I plugged in XSLT (which I know really well) and I thought people might be interested in how I did that. So I thought I'd tell you here. I've got a little but of python that renders JSON type structures to simple XML. So what I do is have a function that I pass an HttpResponse and some JSON and an XSLT filename and it: - turns the JSON into XML - loads the stylesheet from the XSLT filename - pushes the XML through the XSLT - collects the transformation and sends it to the HttpResponse The description is all a bit academic. Here's an example from a real app's views.py: def user_ratings(request, user_name): user = get_object_or_404(User, username=user_name) return send_json(HttpResponse, { "abbr": { "@title": user_name, "div": { "@class": "ratings", "div": [ { "div": { "@class": "looks", "span": user.looks }}, { "div": { "@class": "looks", "span": user.looks }} ]}}}, xslt="user_ratings") Here's another real example from the same app, with a generator: def user_alerts(request, user_name): me = get_object_or_404(User, username=user_name) alerts = Alert.objects.filter(user=me, seen=False) return tfxslt.send_json(HttpResponse(), { "div": [ { "abbr": { "@title": alert.created, "span": alert.message }} for alert in alerts]}, xslt="user_alerts") I think this works quite well; - the programmatic template is actually python, albeit a specialized JSON syntax of python - it's pretty clear what the template is going to result in, as XML - it makes the XSLT pretty simple I've used it on 3 very different projects now and it's been fine on each one. If there's any interest in this I'd consider trying to make my stuff Django-fied enough to fit in sorta properly... maybe if you return a special JSON/XSLT object to an HttpResponse or something. If anyone wants the xslt/json module I'll post it somewhere. On another note is anyone interested in a London meet up? I'd love to have a beer with a few other Django developers and chew the cud. -- Nic Ferrier http://www.tapsellferrier.co.uk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---