On Monday 09 January 2006 08:31, tonemcd wrote:
> Hi all,
> I'm trying to graft additional functionality onto an admin site I have
> running and decided that CSV was a good start...
>
> I have a urlconf that does this;
>     (r'^CSV/$', 'djangomysql.apps.subjcentre.views.change_list'),
>
> and the change_list method in 'views' looks like this;
>
> def change_list(request):
>     app_label='subjcentre'
>     module_name='persons'
>
>     cl = ChangeList(request, app_label, module_name)
>
>     c = Context(request, {
>         'title': cl.title,
>         'is_popup': cl.is_popup,
>         'cl' : cl,
>         'the_result' : cl.result_list,
>     })
>
> I'm hard-coding in both the app_label and the module at the moment.
>
> My view is essentially this;
>
> the_result: {{ the_result }}
> result_list: {% block result_list %}{% result_list cl %}{% endblock %}
>
> For the_result, I get the __repr__ of my 'Person' class, with no HTML
> wrapping - which is a start ;)
> For result_list, I get all the data I want, but it's wrapped in table
> tags...
>
> Is there a simple way of doing this, or is my django-zen not at a
> high-enough level yet ;)
>
> cheers
> Tone

Hi Tone,

Adrian wrote a nice document on outputting csv files:
<http://www.djangoproject.com/documentation/outputting_csv/>

It seems like you should be able apply the recipe to your result_list to get 
it in csv format.

Eric.

Reply via email to