Django Interview

What constitutes  Django templates ?
Answer: Template can create formats like XML,HTML and CSV(which are text based formats). In general terms template is a simple text file. It is made up of variables that will later be replaced by values after the template is evaluated and has tags which will control template’s logic.
2. List some typical usage of middlewares in Django.
Answer: Some of the typical usage of middlewares in Django are: Session management, user authentication, cross-site request forgery protection, content Gzipping, etc.
3. How do you use views in Django? 
Answer: Views will take request to return response.  Let’s write a view in Django :  “example” using template example.html , using  the date-time module to tell us exact time of reloading the page.  Let’s edit a file called view.py, and it will be inside randomsite/randomapp/
To do this save and copy following into a file:
You have to determine the  VIEW first, and then uncomment this line located in fileurls.py
This will reload the site making changes obvious.
4.  How do you make a Django app that is test driven and will display Fibonacci’s sequence?
Answer: Keep in mind that it should take an index number and output the sequence. Additionally, there should be a page that shows the most recent generated sequences.
Following is one of the solution for generating fibonacci series:
Below is a model that would keep track of latest numbers:
For view, you can simply use the following code:
You could use models to get last ‘n’ entities.
5. What makes up Django architecture?
Answer: Django runs on MVC architecture. Following are the components that make up django architecture:
  • Models: Models elaborate back-end stuffs like database schema.(relationships)
  • Views: Views control what is to be shown to end-user.
  • Templates: Templates deal with formatting of view.
  • Controller: Takes entire control of Models.A MVC framework can be compared to a Cable TV with remote. A Television set is View(that interacts with end user), cable provider is model(that works in back-end) and Controller is remote that controls which channel to select and display it through view.
6. What does session framework do in django framework ?
Answer: Session framework in django will store data on server side and interact with end-users. Session is generally used with a middle-ware. It also helps in receiving and sending cookies for authentication of a user.
7. Can you create singleton object in python?If yes, how do you do it?
Answer: Yes, you can create singleton object. Here’s how you do it :
8. Mention caching strategies that you know in Django!
Answer: Few caching strategies that are available in Django are as follows:
  • File sytem caching
  • In-memory caching
  • Using Memcached
  • Database caching
9. What are inheritance type in Django?
Answer: There are 3 inheritance types in Django
  • Abstract base classes
  • Multi-table Inheritance
  • Proxy models
10. What do you think are limitation of Django Object relation mapping(ORM) ?
Answer: If the data is complex and consists of multiple joins using the SQL  will be clearer.
If Performance is a concern for your, ORM aren’t your choice. Genrally. Object-relation-mapping are considered good option to construct an optimized query, SQL has an upper hand when compared to ORM.
These Django interview questions are subjective on our experience and your mileage may vary.
The questions above are only about knowledge about domain of an individual and doesn’t test your problem solving aptitude, ability to research and learn new skills.

Comments

Popular Posts