Login

Tag "httpresponse"

Snippet List

ExcelResponse2

A function extends of Tarken's django-excel-response django-excel-response 1、djangosnippets - http://djangosnippets.org/snippets/1151/ 2、pypi - https://pypi.python.org/pypi/django-excel-response/1.0 When using Tarken's django-excel-response. We find that Chinese is messed code when we open .xls in Mac OS. As discussed in http://segmentfault.com/q/1010000000095546. We realize django-excel-response2 Based on Tarken's django-excel-response to solve this problem By adding a Param named font to set font.

  • output
  • httpresponse
  • excel
  • cvs
Read More

Doing redirect without request

When you neeed to do redirect and request object is not available, you can do it with exception. Put exception handler somewhere request is available, for example to middleware or ModelAdmin. Raise exception, where request is not available.

  • http
  • request
  • redirect
  • reverse
  • httpresponse
Read More

ExcelResponse

A subclass of `HttpResponse` which will transform a `QuerySet`, or sequence of sequences, into either an Excel spreadsheet or CSV file formatted for Excel, depending on the amount of data. All of this is done in-memory and on-the-fly, with no disk writes, thanks to the StringIO library. **Requires:** [xlwt](http://pypi.python.org/pypi/xlwt/) **Example:** def excelview(request): objs = SomeModel.objects.all() return ExcelResponse(objs)

  • csv
  • output
  • httpresponse
  • excel
Read More

401 HttpResponse

This is a HTTP response is use in my application when I want to return a 401. It's pretty simple, but effective for my needs.

  • 401
  • httpresponse
Read More

4 snippets posted so far.