Re: utf-16le encode generic view object_list

2015-05-22 Thread JHeasly
@Tim: render_to_string! Forgot about that, somehow. That could clean it up 
a bit. Thanks!

@Stephen: Thanks for the feedback. This app's running internally and is on 
insecure and ancient 1.4, but the mimetype parameter reminder is a good 
one! Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff1a98cf-8cdc-475d-aeb4-516564d741f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: utf-16le encode generic view object_list

2015-05-22 Thread Stephen J. Butler
I think that looks fine. I would change the mimetype to "text/plain;
charset=UTF-16LE" just to play nice, but it probably will never matter
with your Content-Disposition. Also, HttpResponse's mimetype parameter
has been deprecated since 1.5; use content_type instead.

On Thu, May 21, 2015 at 3:04 PM, JHeasly  wrote:
> Hello all,
>
> I've got a function-based generic view that I want to return a utf-16le
> encoded response (for use as an InDesign tagged text file; the utf-16le is
> what InDesign wants). I've got it working here, but am wondering if there's
> an more straightforward way.
>
> For comparison, the "original" utf-8 encoded version is here and shorter. I
> tried a
>
> response.content.encode('utf-16le')
>
> as response seems to have some sort of HttpResponse wrapper on it.
>
> Thanks,
> John
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/396a9248-5930-43d9-a3bb-43154fd2ae9b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxX35fr1CBNNumS6eRyKOgbKk4vNrcuFW%3Dyr4Hmkeb-4sA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: utf-16le encode generic view object_list

2015-05-21 Thread Tim Chase
On 2015-05-21 13:04, JHeasly wrote:
> I've got a function-based generic view that I want to return a
> utf-16le encoded response (for use as an InDesign tagged text file;
> the utf-16le is what InDesign wants). I've got it working here 
> , but am
> wondering if there's an more straightforward way.
> 
> For comparison, the "original" utf-8 encoded version is here 
>  and shorter.
> I tried a 
> 
> response.content.encode('utf-16le')
> 
> as response seems to have some sort of HttpResponse wrapper on it.

you could reduce the verbosity by using render_to_string()

https://docs.djangoproject.com/en/1.7/ref/templates/api/#the-render-to-string-shortcut


but otherwise, I suspect the extras code is just the cost of doing
something off the ordinary path.

-tkc




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20150521152535.162c8d66%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.