Just another programmer's site

Category: Django

Django: copy model instance

To copy model instance, replacing pk value is the easiest way.

Python: get post parameters from response object (requests)

In requests, response object has PreparedRequest object and it only contains ‘raw’ post request parameters (not as dict).

To parse the raw params to dict using urlparse.parse_qs method works, but it makes values to list despite a single value.

In Django, using django.http.QueryDict works fine!

Django: csrf_exempt of class based view

To suppress csrf verification of class based view, @csrf_exempt decorator in doesn’t work in Django 1.4 .

Instead, decorating the as_view function in works fine!


© 2019

Theme by Anders NorenUp ↑