Skip to main content



How to disable auto strip in Charfield in Django

·2 mins
In Django, when edit field in admin page or post data to forms, the leading and tailing whitespace in CharField and TextField are removed. The reason is strip=True parameter in forms.CharField, which is added in Djagno 1.9. You can see the discussion in django tiket #4960 and here is source code.

Using JSONField before Django 3.1

·2 mins
In Django 3.1, Django support save python data into database as JSON encoded data and it is also possible to make query based on field value in JSONField. The detailed usage can be found here. If you are using older version and want to try this feature.


CSRF in Django

·2 mins
CSRF(Cross-site request forgery) is a way to generate fake user request to target website. For example, on a malicious website A, there is a button, click it will send request to When the user click this button, he will logout from website B unconsciously.