Hello I've been using Django for a week. Really liking its flexibility. I'm using it to create a CMS for an ActionScript 3 app. The Flash will read an XML file outputed from Django and maintained through the admin interface. It's all working well but I have a problem structuring the XML output in my view/template. Have gone through docs but can't figure this out.
The view is as follows: import django.http as http import django.shortcuts as shortcuts import models def xml(request): # References to Model categories = models.Category.objects.order_by('name') clients = models.Client.objects.order_by('name') items = models.Item.objects.order_by('name') return shortcuts.render_to_response("/home/benmarinic/webapps/ django/portfolio/templates/portms/data.xml", dict(categories=categories, clients=clients, items=items)) //********************************// The template is: <?xml version="1.0" encoding="UTF-8"?> <categories> {% for category in categories %} <category> <title><![CDATA[{{category.name}}]]></title> <clients> {% for client in clients %} <client> <title><! [CDATA[{{client.name}}]]></title> </client> {% endfor %} </clients> </category> {% endfor %} </categories> </xml> The XML is currently outputing the same client list for all categories. But this is bot setup that way in the admin tool - I have ForeignKey and it's all working fine in admin. I have some clients in certain categories and not in others. I can't get my head around modifying the template and or the view to output only the client in the given category. The XML should read something like this: <?xml version="1.0" encoding="UTF-8"?> <categories> <category> <title><![CDATA[Category 1]]></title> <clients> <client> <title><![CDATA[Client 1]]></title> </client> <client> <title><![CDATA[Client 2]]></title> </client> </clients> </category> <category> <title><![CDATA[Category 2]]></title> <clients> <client> <title><![CDATA[Client 4]]></title> </client> <client> <title><![CDATA[Client 5]]></title> </client> </clients> </category> </categories> </xml> Thanks Ben --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---