Featured post

Quiz: Data PreProcessing

Saturday, 25 January 2020

Python Django Interview Questions & Answers

Python Django Interview Questions & Answers

Question: What are Django shortcut functions?
Ans: The package django.shortcuts collects helper functions and classes that “span” multiple levels of MVC. These functions/classes introduce controlled coupling for convenience’s sake.
More Read 

Question: What is the function of render()?
Ans: render() Combines a given template with a given context dictionary and returns an HttpResponse object with that rendered text. Django does not provide a shortcut function which returns a TemplateResponse because the constructor of TemplateResponse offers the same level of convenience as render() .

Question: What is the diff between {{ }} and {% %}?
Ans: There are three category in the template in Django
1> Template Variable {{ }}: To render variables in the template or displaying variables.
2> Template Tag {% %}: For sentences such as if and for or to call tags such as load, static, etc.
3> Template Filter:  {{variable |filter:arg}}

Question:What does CSRF token mean?
Ans: Cross-site request forgery, also known as one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website where unauthorized commands are transmitted from a user that the web application trusts.

Question: How does Django CSRF work?
Ans: When receiving the form submission, Django checks that the alphanumeric string value from the hidden form field matches and the csrftoken cookie received from the browser. ... A CSRF attack might come in the form of a malicious web site that includes an iframe. The iframe includes a POST form and some JavaScript.

Question: How long is CSRF token?
Ans: That said, assuming an attacker can do 100,000 requests per second, it should take around 2.93 million years on average to brute force a 64-bit CSRF token. (And there shouldn't be more than one token in the whole token space, unlike with session id's.) So, maybe 64 bits is enough.

No comments:

Post a Comment