Python Django

How To Enable Or Disable CSRF Validation In Django Web Application

Django has provided a feature that can help you to avoid csrf attacks on your Django application. But sometimes especially in your development environment, you do not want this feature when sending post requests to your web server use curl in the command line, if this feature is enabled, you will get errors. This article

How To Enable Or Disable CSRF Validation In Django Web Application Read More »

How To Return Html File As Django View Response

Morden web application are all designed with MVC( Model, View, Controller ) pattern. But in django, the pattern name is MTV( Model, Template, View Function ). So in django, template html is the view, and view function plays the role of controller. This article will tell you how to create template and view function in

How To Return Html File As Django View Response Read More »

How To Use Django url Tag And reverse() Function To Avoid Url Hard Coded

Hard coded url in your Django template html files or views.py file is a bad practice. Because it is difficult to maintain url changes. If you change one url, you may need to change that url in a lot of pages. So Django provide template url tag and reverse function for you to avoid hard

How To Use Django url Tag And reverse() Function To Avoid Url Hard Coded Read More »

How To Get Many To Many Model Field Values In Django View

We have learned how to add many to many fields for Django models in the article How To Operate Foreign Key And Many To Many Field In Django Model. But when we display the many to many field values ( in this example is the Employee’s Department values ) in Django Html template page, we

How To Get Many To Many Model Field Values In Django View Read More »

What Does Double Underscore ( __ ) Means In Django Model QuerySet Objects Filter Method

You have learnd how to use Django model manager’s filter or exclude method to get query result data in article Django Simple CRUD Operation Example. To use filter method is so easy as below. Department.objects.filter(dept_desc__contains=’dev2qa’) <QuerySet [<Department: Development,Develop dev2qa.com website use Django>]> We can see that the filter function’s argument is dept_desc__contains=’dev2qa’, i think this is not difficult

What Does Double Underscore ( __ ) Means In Django Model QuerySet Objects Filter Method Read More »