how it works
1, the middle ware 'django.middleware.csrf.CsrfViewMiddleware' to your list of middleware classes.
2, On server side the csrf is csrf_token like:
<form action="." method="post">{% csrf_token %}You may need manually update the csrf by:
from django.core.context_processors import csrf from django.shortcuts import render_to_response def my_view(request): c = {} c.update(csrf(request)) return render_to_response("a_template.html", c)
3,if you already added the the csrf middleware and you do not want to apply it, you should added
@csrf_exempt
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
return HttpResponse('Hello world')
it is very import to added @csrf_exempt if you want to use ajax in django framework.
This comment has been removed by the author.
ReplyDelete
ReplyDeleteThis is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
angularjs Training in bangalore
angularjs Training in electronic-city
angularjs Training in online
angularjs Training in marathahalli
Really you have done great job,There are may person searching about that now they will find enough resources by your post
ReplyDeletepython interview questions and answers | python tutorials
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteJava training in Chennai | Java training in Bangalore
Java interview questions and answers | Core Java interview questions and answers
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeleteData Science Training in Chennai | Data Science training in anna nagar
Data Science training in chennai | Data science training in Bangalore
Data Science training in marathahalli | Data Science training in btm layout
Informative Blog, Thank you to share this
ReplyDeleteRegards,
Best Devops Training in Chennai | Best Devops Training Institute in Chennai
I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll.
ReplyDeleteDevops Training in Chennai | Devops Training Institute in Chennai
Nice article Thanks for sharing this article Wonderful information from this website Thanks !!!c Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery
ReplyDeleteUseful post.interesting article.Keep blogging.
ReplyDeleteJava training in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Online Training
Your blog is very interesting. Your level of thinking is good and the clarity of writing is excellent. I enjoyed reading this post. I am also a blogger, You can visit our services here Android App Development Services
ReplyDeleteYou can also contact here, if you are looking forward to Hire Android App Developers or best Mobile App Development Company
Always use Django's POST method with CSRF protection for your web apps security. A typical vulnerability I've seen is Cross-Site Request Forgery, CSRF, and Django has built in CSRF middleware for mitigating this. This will let you embed a CSRF token into your forms to guarantee that your forms receive only trusted requests. Combining this security measure with a custom sales funnel landing page design can provide a seamless user experience on top of user and application security.
ReplyDelete