On 5/25/06, mary <[EMAIL PROTECTED]> wrote:
>
> i wrote this view
> def index(request):
> output=open( '/var/www/xml-python/xmleditor/test.xml','w')
> output.write('<?xml version="1.0" encoding="iso-8859-1"?>')
> output.write('<content_topnav>')
> latest_menu_list = Menu.objects.all().order_by('-id')
> output = ', '.join([m.menu_text for m in latest_menu_list])
> output.write(output)
>
>
>
> return HttpResponse(output)
>
> and i got this error
> 'str' object has no attribute 'write'
>
>
> can anyone help please
>
> Thanks,
> Mary
>
>
When you do this:
output = ', '.join([m.menu_text for m in latest_menu_list])
you rebound the name 'output' to a string, it no longer references
your file descriptor. Try this:
output_str = ', '.join([m.menu_text for m in latest_menu_list])
output.write(output_str)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---