Skip to main content

Django Interview Questions and Answers

Q1).Explain what is Django?
Ans1: Django is a web framework in python to develop a web application in python.
Django is a free and open source web application framework, written in Python.
Q2).Mention what are the features available in Django?
Ans2: Features available in Django are
  • Admin Interface (CRUD)
  • Templating
  • Form handling
  • Internationalization
  • Session, user management, role-based permissions
  • Object-relational mapping (ORM)
  • Testing Framework
  • Fantastic Documentation
Q3).Mention the architecture of Django architecture?
Ans3: Django architecture consists of
  • Models: It describes your database schema and your data structure
  • Views: It controls what a user sees, the view retrieves data from appropriate models and execute any calculation made to the data and pass it to the template
  • Templates: It determines how the user sees it. It describes how the data received from the views should be changed or formatted for display on the page
  • Controller: The Django framework and URL parsing
Q4).Why Django should be used for web-development?
Ans4:
  • It allows you to divide code modules into logical groups to make it flexible to change
  • To ease the website administration, it provides auto-generated web admin
  • It provides pre-packaged API for common user tasks
  • It gives you template system to define HTML template for your web page to avoid code duplication
  • It enables you to define what URL be for a given function
  • It enables you to separate business logic from the HTML
  • Everything is in python
Q5). Explain how you can create a project in Django?
Ans5: To start a project in Django, you use command $ django-admin.py and then use the command
Project
_init_.py
manage.py
settings.py
urls.py
Q6). Explain how you can set up the Database in Django?
Ans6: You can use the command edit mysite/setting.py , it is a normal python module with module level representing Django settings.
Django uses SQLite by default; it is easy for Django users as such it won’t require any other type of installation. In the case your database choice is different that you have to the following keys in the DATABASE ‘default’ item to match your database connection settings
  • Engines: you can change database by using ‘django.db.backends.sqlite3’ , ‘django.db.backeneds.mysql’, ‘django.db.backends.postgresql_psycopg2’, ‘django.db.backends.oracle’ and so on
  • Name: The name of your database. In the case if you are using SQLite as your database, in that case database will be a file on your computer, Name should be a full absolute path, including file name of that file.
If you are not choosing SQLite as your database then setting like Password, Host, User, etc. must be added.
Q7). Give an example how you can write a VIEW in Django?
Ans7: Views are Django functions that take a request and return a response.  To write a view in Django we take a simple example of “Guru99_home” which uses the template Guru99_home.html and uses the date-time module to tell us what the time is whenever the page is refreshed.  The file we required to edit is called view.py, and it will be inside mysite/myapp/
Copy the below code into it and save the file
       from datatime import datetime
      from django.shortcuts import render
     def home (request):
return render(request, ‘Guru99_home.html’, {‘right_now’: datetime.utcnow()})
Once you have determined the VIEW, you can uncomment this line in urls.py
# url ( r ‘^$’ , ‘mysite.myapp.views.home’ , name ‘Guru99’),
The last step will reload your web app so that the changes are noticed by the web server.
Q8).Explain how you can setup static files in Django?
Ans8: There are three main things required to set up static files in Django
  • Set STATIC_ROOT in settings.py
  • run manage.py collectsatic
  • set up a Static Files entry on the PythonAnywhere web tab
Q9).Mention what does the Django templates consists of?
Ans9: The template is a simple text file.  It can create any text-based format like XML, CSV, HTML, etc.  A template contains variables that get replaced with values when the template is evaluated and tags (% tag %) that controls the logic of the template.
Q10). Explain the use of session framework in Django?
Ans10: In Django, the session framework enables you to store and retrieve arbitrary data on a per-site-visitor basis.  It stores data on the server side and abstracts the receiving and sending of cookies.  Session can be implemented through a piece of middleware.

Comments

Popular posts from this blog

SAP GRC Interview Questions and Answers

1.What is the use of  SAP GRC? SAP Governance , Risk and Compliance solution enables organization to manage regulations and compliance and remove any risk in managing organizations key operations. As per changing market situation organizations are growing and rapidly changing and inappropriate documents, spreadsheets are not acceptable for external auditors and regulators. 2.What are the different activities that you can perform in SAP GRC? SAP GRC helps organization to manage their regulations and compliance and you can perform following activities Easy integration of GRC activities into existing process and automating key GRC activities. Low complexity and managing risk efficiently. Improve risk management activities. Managing fraud in business processed and audit management effectively. Organizations perform better and companies can protect their values. SAP GRC solution consists of three main areas: Analyze, manage and monitor. 3.What are the different GRC modul

Zend Framework Interview Questions and Answers

1.What is a   Framework ? In software development, a framework is a defined support structure in which another software project can be organized and developed. An abstract design  Set of common functionality  Developed for a particular domain   2.How to disable layout from controller? $this->_helper->layout()->disableLayout(); Disable Zend Layout from controller for Ajax call only if($this->getRequest()->isXmlHttpRequest()){ $this->_helper->layout()->disableLayout(); } 3.How to change the View render file from controller? function listAction(){ //call another view file file $this->render(“anotherViewFile”); } 4.How to protect your site from sql injection in zend when using select query? $select = $this->select() from(array(‘u’ => ‘users’), array(‘id’, ‘username’)) where(‘name like ?’,”%php%”) where(‘user_id=?’,’5′) where(‘rating<=?’,10); 5.How to check post method in zend framework? if($this->getReque

Apache Kafka Interview Questions and Answers

Q1) .Mention what is Apache Kafka? Ans:   Apache Kafka is a publish-subscribe messaging system developed by Apache written in Scala. It is a distributed, partitioned and replicated log service. Q2). Mention what is the traditional method of message transfer? Ans:   The traditional method of message transfer includes two methods   Queuing: In a queuing, a pool of consumers may read message from the server and each message goes to one of them •   Publish-Subscribe: In this model, messages are broadcasted to all consumers Kafka caters single consumer abstraction that generalized both of the above- the consumer group. Q3). Mention what is the benefits of Apache Kafka over the traditional technique? Ans:   Apache Kafka has following benefits above traditional messaging technique Fast: A single Kafka broker can serve thousands of clients by handling megabytes of reads and writes per second •   Scalable : Data are partitioned and streamlined over a cluster of machines to en