views:

219

answers:

2

Hi guy, how ill write a xml file for use with flash?, Django Doc dont have nothing about XML (just for Feeds)....

Tutorial?

Thansk

+1  A: 

Quoting the start of the Django documentation on templates:

A template is simply a text file. It can generate any text-based format (HTML, XML, CSV, etc.).

Your view will look something like this:

from django.shortcuts import render_to_response

def your_view(request)
    context_data = {'extra': stuff}
    return render_to_response('your_xml_template.xml', context_data,
                              mimetype='application/xml')
SmileyChris
Thanks SmileyChris :)
Asinox
Thanks is working, Django is GOD
Asinox
+1  A: 

You can even use one of the handy generic views to easily generate XML using data from one of your models. Something like this could go into your urls.py file:

urlpatterns = ('django.views.generic.list_detail',
    (r'^mymodel-(?P<object_id>\d+).xml$', 'object_detail', {'queryset': MyModel.objects.all(),
                                                            'template_name': 'your_xml_template.xml',
                                                            'mimetype': 'application/xml'}),
   (... more url patterns ...),
)

All you have to do is write the XML template.

Gonzalo
Thanks Gonzalo :)
Asinox