1. What is Django ?

Django is a high-level Python-based free and open-source web framework, which follows the model-view-template architectural pattern.

2. What is latest and stable version of Django ?

The latest and stable version  is version 3.0

3. Why django ? What is advantages of Django ?

Its free and open source, it makes the web development process very easy and the developer can fully focus on the designing process and boost performance. It is an ideal tool for startups, where web design is the need to bring out the real concept and prospects of the company.

It makes it easier to build web apps more quickly and with less code, It is also ridiculously fast, reassuringly secure and exceedingly scalable.

4. What are features of Django ?

Django’s features are: Rapid Development, Secure, Scalable, Fully Loaded, Versatile, Open Source, Vast and Supported Community.

5. What id CRUD ?

CRUD means Create, Read, Update and Delete. It provides a memorable framework for reminding developers of how to construct full, usable models when building application programming interfaces (APIs).

6. What are disadvantages of Django ?

Django’s disadvantages are that the URL specifying with regular expressions is not an easy task to accomplish, at least for beginners, It’s a strongly opinionated framework, which gives it a monolithic feeling. Also, template errors fail silently by default,.

7. Explain the architecture of Django?

Django Architecture is based on Model View Controller (MVC) pattern. It consists of 3 different parts:

The Model which is the logical data structure behind the complete application & represents by a Database.

The View which is the user interface that you see in the browser whenever you visit a website.

The Controller which is the middleman that connects the view & model together.

8. Can you explain the working philosophy of Django?

Django’s working philosophy can be broken into many components:

Models.py file: This file defines your data model by extending your single line of code into full database tables and add a pre-built administration section to manage content.

Urls.py file: It uses a regular expression to capture URL patterns for processing.

Views.py file: It is the main part of Django. The actual processing happens in view.

When a visitor lands on Django page:

Django checks the various URLs pattern you have created and uses the information to retrieve the view.

The view processes the request, querying your database if necessary.

The view passes the requested information on to your template.

The template renders the data in a layout you have created and displays the page.

9. What is MVT and MVC, How it’s related to Django?

A common way of explaining Django’s architecture in terms of MVC is to describe it as a Model-View-Template (MVT). There’s no difference between MTV and MVT, by the way – they’re two different ways of writing exactly the same thing, which just adds to the confusion.

10. How to install django ?

To install Django, we need to download and install Python as required depending on the operating system in use. t’s recommended  to create a virtual environment. Run the command pip install “django>=2.2,<3” on the terminal and wait until it’s successfully installed.

11. How to check the latest version of Django?

To check the latest version of Django, visit their homepage https://www.djangoproject.com/ and on the right of the page you’ll see a “Download latest release” button with the latest version on it.

12. How can you setup Database in Django?

Create the initial Django project skeleton by using the django-admin startproject command.

Open the settings from the settings.py file to confirm all settings such as your timezone are suitable for your project, else make changes or add new settings where necessary.

 

Install MySQL Database Connector.

Create the database.

Add the MySQL Database Connection to your Application.

Test MySQL Connection to Application.

13. What is the list of backends supported by django ?

Backends include: IBM DB2, Microsoft SQL Server, Firebird and ODBC.

14. Can i Connect mysql to django ?

Yes

15. Can i Connect plsql to django ?

Yes

16. How to connect mongodb in Django ?

MongoDB can be connected to Django by adding the DATABASES object with its default object in the settings.py file and specifying the ENGINE’s value as django and the NAME’s value as the name of the MongoDB database you want to connect to.

17. How can you set up static files in Django?

Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS.

In your settings file, define the STATIC_URL to the folder path string where your static files will be placed and make sure the folder exists.

In your templates, use the static template tag to build the URL, for the given relative path using the configured STATICFILES_STORAGE.

 

Store your static files in the static folder you specified. In addition to using a static directory inside your app, you can define a list of directories (STATICFILE_DIRS) in your settings file where Django will also look for static files.

18. What is the use of session framework in Django?

Session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server-side and abstracts the sending and receiving of cookies each containing a session ID unless you are using a cookie-based backend.

19. What is the usage of middlewares in Django?

Middlewares are used  go to modify the request i.e. HttpRequest object which is sent to the view, to modify the HttpResponse object returned from the view and to perform an operation before the view executes.

20. What are the roles of receiver and sender in signals?

The receiver is the callback function which will be connected to a signal

The sender specifies a particular sender to receive signals from.

21. What does Django templates contain ?

Django templates contains the static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.

22. How to create super user in django ?

To create a super user,,

Create project using the django-admin startproject command.

Move into the project location and run python manage.py makemigrations && python manage.py migrate && python manage.py createsuperuser.

23. How to create simple application in django ?

To create a simple application  use the command django-admin startproject followed by the application’s name.

24. What is ORM ? Advantages of ORM ?

ORM (Object-relational mapping) is a programming technique for converting data between incompatible type systems using object-oriented programming languages.

 

Advantages include:

Concurrency support

Cache management

25. How to create a model in django ?

Add the model object in the models.py file, updated settings for the newly created app by adding it to the INSTALLED_APPS section in settings.py, make migrations, and verify the database schema.

26. What is migration in django ?

Migrations are a way of propagating changes made in the model into the database schema (adding a field, deleting a model, etc.)

27. How to do migrations in django ?

To do migrations , create or update a model and in the app directory, run the command ./manage.py makemigrations <app name> && ./manage.py migrate <app name>

28. How to clear cache in django ?

To clear cache, run the clear() method from django.core.cache in a python script.

29. What is Rest API ?

A REST API is an application program interface that uses HTTP requests to GET, PUT, POST and DELETE data.

30. How to Create APIs in Django ?

Create a project directory,  create python virtual environment,   and activate it, install Django and djangorestframework using the pip install command. In the same project directory, create  project using the command django-admin.py startproject api. Start the app. Add the rest_framework and the Djano app to INSTALLED_APPS to settings. Open the api/urls.py and add urls for the Django app. We can then create models and make migrations, create serializers, and finally wiring up the views.

31. What is DRF of Django Rest Frame work ?

Django Rest Framework (DRF) is a powerful module for building web APIs. It’s very easy to build model-backed APIs that have authentication policies and are browsable.

32. How to Fetch data from apis using Django ?

We use the Fetch API and SessionAuthentication  by adding it to the settings.py file on the server and on the client, include  the getCookie method. Finally, use the fetch method to call your endpoint.

33. How to update the data from apis ?

We update data by sending PUT requests. Add a new path in the data model urlpatterns from which the update will be sent to. We then add an update method to the serializer that will do the update.

34. What is Authentication ?

Authentication is the process or action of verifying the identity of a user or process.

35. Types of Authentication in REST API ?

Token based authentication and Session based authentication.

36. What is token based authentication system ?

A token based authentication system is a security system that authenticates the users who attempt to log in to a server, a network, or some other secure system, using a security token provided by the server.

37. Can i use django apis in mobile application development ?  

Yes

38. Explain Mixins in Django ?

A mixin is a special kind of multiple inheritance. There are two main situations where mixins are used: to provide a lot of optional features for a class and to use one particular feature in a lot of different classes.

39. Different types caching strategies in django ?

Different types of  caching strategies  include Filesystem caching, in-memory caching, using memcached and database caching.

40. How a request is process in Django ?

When the user makes a request of your application, a WSGI handler is instantiated, which:

imports your settings.py file and Django’s exception classes.

loads all the middleware classes it finds in the MIDDLEWARE_CLASSES or MIDDLEWARES(depending on Django version) tuple located in settings.py

builds four lists of methods which handle processing of request, view, response, and exception.

loops through the request methods, running them in order

resolves the requested URL

loops through each of the view processing methods

calls the view function (usually rendering a template)

processes any exception methods

loops through each of the response methods, (from the inside out, reverse order from request middlewares)

finally builds a return value and calls the callback function to the web server.

41. When to use iterator in Django ORM ?

The iterator is used when  processing results that take up a large amount of available memory (lots of small objects or fewer large objects).

42. What are signals in Django ?

Signals allow certain senders to notify a set of receivers that some action has taken place. They’re especially useful when many pieces of code may be interested in the same events.

How to implement social login authentication in Django ?Run the development server to make sure all is in order. The install python-social-auth using the pip install command. Update settings.py to include/register the library in the project  Update the database by  making migrations. Update the Project’s urlpatterns in urls.py to include the main auth URLs. Create a new app https://apps.twitter.com/app/new and make sure to use the callback url http://127.0.0.1:8000/complete/twitter. In the project directory, add a config.py file and grab the consumer key and consumer secret and add them to the config file. Finally add urls to the config file to specify the login and redirect urls. Do a sanity check and add friendly views.

43. Where to store static files in django ?

Static files are stored in the folder called static in the Django app.

Types of Session handling methods in Django

Session handling types  include database-backed sessions, Using cached sessions, Using file-based sessions, and Using cookie-based sessions.

44. What does Of Django Field Class types do?

The database column type

The widget to use ’s forms and admin site,.

he minimal validation requirements, which are used ’s admin interface and by forms.

45. How to use file based sessions?

To use file-based sessions, set the SESSION_ENGINE setting to “django.contrib.sessions.backends.file” or the SESSION_FILE_PATH setting (which defaults to output from tempfile.gettempdir(), most likely /tmp) to control where Django stores session files. Be sure to check that your Web server has permissions to read and write to this location.

46. Is Django Open source ?

Yes

47. How to set and unset session in django ?

To set a session , set a key and a value in the session object. To unset a session Django, use the in-built Python del keyword to delete the session by specifying the key.

48. How to create views in django ?

To create views , create and activate a virtual environment.  Create a file called views.py for example and create view functions to render views using the HttpResponse object in this file and  map URLs to views by adding the path to urlpatterns in the urls.py file.

 

49. Where to store static files in django ?

Static files are stored in the folder called static in the Django app.

50. Types of Session handling methods in Django?

Session handling types  include database-backed sessions, Using cached sessions, Using file-based sessions, and Using cookie-based sessions.