ats-min.com

Just another programmer's site

Category: Django

Django: copy model instance

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

http://stackoverflow.com/questions/4733609/how-do-i-clone-a-django-model-instance-object-and-save-it-to-the-database

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 veiws.py doesn’t work in Django 1.4 .

http://stackoverflow.com/questions/10252238/csrf-exempt-stopped-working-in-django-1-4#comment13230749_10252521

Instead, decorating the as_view function in urls.py works fine!

 

© 2018 ats-min.com

Theme by Anders NorenUp ↑