

{"id":52944,"date":"2019-04-01T11:30:45","date_gmt":"2019-04-01T06:00:45","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=52944"},"modified":"2021-06-21T12:19:37","modified_gmt":"2021-06-21T06:49:37","slug":"django-views","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/django-views\/","title":{"rendered":"Django Views &#8211; 6 Simple Steps to Create View Component for Django Project"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1516,&quot;href&quot;:&quot;https:\\\/\\\/www.djangoproject.com\\\/start\\\/overview&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251002061548\\\/https:\\\/\\\/www.djangoproject.com\\\/start\\\/overview\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 09:53:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-16 19:00:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-27 17:16:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-02 10:51:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-05 12:35:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-15 19:58:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-22 17:14:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-28 13:36:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-02 12:53:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-07 04:40:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 05:48:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 06:44:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 10:25:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 00:22:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 04:46:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 04:38:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 07:25:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 10:14:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-27 21:54:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 08:40:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-07 13:28:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-13 11:28:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-22 09:17:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-27 17:54:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-04 12:04:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-08 12:01:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-11 17:20:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-15 14:09:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-22 08:56:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-05-26 15:06:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-01 14:35:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-05 06:04:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-08 23:42:31&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-08 23:42:31&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>In this tutorial, we will learn about the view component of Django in detail, discuss the difference between class-based views and function-based views and the process of creating views in Django. Before starting this tutorial, we recommend you to complete <strong><a href=\"https:\/\/data-flair.training\/blogs\/django-models\/\">Django models tutorial<\/a><\/strong> as we will be learning how to access the data of models in view.<\/p>\n<p>Django as an MVC architecture follows one design philosophy, loosely coupled. By loosely coupled we mean that modifying an individual component should have a small to no effect on other components.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-52961\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg\" alt=\"Django Views\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p>We will first discuss the view component of the MVC.<\/p>\n<h2>Django Views Component<\/h2>\n<h3>1. Views in MVC Architecture<\/h3>\n<p>View\u00a0is a component in <strong><a href=\"https:\/\/data-flair.training\/blogs\/django-architecture\/\">Django MVC architecture<\/a><\/strong> that contains the logic which is to be displayed to the user. In a traditional MVC architecture, it implements that by coordinating with both model and controller. It\u00a0poses a problem that the views depends on both model and controller so it renders by two components. This violates the design philosophy of MVC since one component is dependent on other components too much.<\/p>\n<p>Website design changes much often than the business logic and view most of the times contain both of them thus coordinating with both the controller and model. This makes it difficult for front-end and back-end developers to coordinate their data with components for displaying.<\/p>\n<h3>2. Views in MTV Architecture<\/h3>\n<p>The above-mentioned problems were solved by\u00a0<strong><a href=\"https:\/\/data-flair.training\/blogs\/django-mtv-architecture\/\">Django\u2019s MTV architecture<\/a><\/strong> where the view was only containing the business logic, i.e., which webpage to be rendered at what input and also became a mediator between the model and template.<\/p>\n<p>One of the important questions that arise from here &#8211;<strong> Is view the controller in Django?<\/strong><\/p>\n<p>The answer is &#8216;no&#8217; because\u00a0Django Views are only corresponding to the particular template, they are technically not selecting a model or view by themselves.<\/p>\n<p>This question arises because it is the work of the controller in MVC to select the view for the particular data.<\/p>\n<p>Now, the question that would be arising in your mind &#8211; <strong>Which component is the controller?<\/strong><\/p>\n<p>Actually, it\u2019s the\u00a0Django Framework itself and therefore, it\u2019s the best framework because the controller is the most complex part of the code as it has to control and communicate with every component, efficiently. Therefore, it needs to be written precisely and that is solved by <strong><a href=\"https:\/\/data-flair.training\/blogs\/django-tutorial\/\">the Django Framework.<\/a><\/strong><\/p>\n<p>Now, we will discuss the difference between the views supported by Django; Class- based Views and Function-based Views.<\/p>\n<h2>Class-Based Views vs Function-Based Views<\/h2>\n<p><strong>Class-Based Views<\/strong><\/p>\n<p>Django firstly started with only Function-Based Views, but then added Class-Based Views as a way to templatize functionality. Therefore, we didn&#8217;t have to write boilerplate (i.e. the same code) code over and over again. CBVs is a way to increase productivity and create it so that we don&#8217;t have to write much code.<\/p>\n<p>Organization of code in relation to specific HTTP methods (GET, POST, etc.) displays as separate methods instead of conditional branching.<\/p>\n<p>Object directed techniques like mixins (multiple inheritances) factors code into reusable components.<br \/>\nThe Class-Based Views don\u2019t take place of Function-Based Views but thanks to the inheritance they are easy in implementing and are more optimal.<\/p>\n<p><strong>Function-Based Views<\/strong><\/p>\n<p>A View function, or view for short, is a <a href=\"https:\/\/data-flair.training\/blogs\/python-function\/\"><strong>Python function<\/strong><\/a> that takes a Web request and gives a Web response. This response is the HTML contents of a Web page, or an XML document, or a redirect, or a 404 error, or an image. The View itself consists of whatever arbitrary logic requires to return that response.<\/p>\n<p>This function is easy in implementing and it\u2019s quite useful but the main drawback is that on a large size Django project, there are generally many similar functions in the views. One instance is that all objects of a <strong><a href=\"https:\/\/data-flair.training\/blogs\/create-django-project\/\">Django project <\/a><\/strong>have CRUD operations, therefore this code repeats unnecessarily. This was the main reason for the creation of Generic Class-based views.<\/p>\n<h2>Creating Django Views in Easy Steps<\/h2>\n<p>In the previous tutorial we generated a model now we will be connecting our model with the view. We have actually used view.py in our <strong><a href=\"https:\/\/data-flair.training\/blogs\/create-install-deploy-django-app\/\">Django App tutorial<\/a><\/strong> but here we will perform it\u00a0again from the beginning.<\/p>\n<p>Here are the steps to create Django views for our project:<\/p>\n<p><strong>Step 1. <\/strong>In our student app directory create a new python file named urls.py.<\/p>\n<p><strong>Step 2.<\/strong> Inside that file copy this code as it is.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">from django.urls import path\r\nfrom . import views\r\nurlpatterns = [\r\npath('', views.student_show, name = 'student_show'),\r\n]<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-52955\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command.png\" alt=\"Django Views - student show command\" width=\"868\" height=\"195\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command.png 868w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command-150x34.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command-300x67.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command-768x173.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-show-command-520x117.png 520w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/a><\/p>\n<p><strong>Understanding the code:<\/strong><\/p>\n<p>Here, we are creating a urls file for our application rather than the whole project. This urls file will contain all the URLs inside it related to our app. Thus, we get a cleaner main urls_config file.<\/p>\n<p>Now, we will be connecting our project with the application.<\/p>\n<p><strong>Step 3.<\/strong> Open the urls.py file of the project that is in the root folder.<\/p>\n<p><strong>Step 4.<\/strong> Now add this item in the urlpatterns list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">path(\u2018student\/\u2019, include(\u2018student.urls\u2019)),<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-52956\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command.png\" alt=\"Django Views - student urls command\" width=\"769\" height=\"320\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command.png 769w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command-150x62.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command-300x125.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command-768x320.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/student-urls-command-520x216.png 520w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/a><\/p>\n<p><strong>Understanding the Code:<\/strong><\/p>\n<p>This code is actually directing our main urls file to locate and run urls file in the student directory when the URL contains the ending as student\/.<\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/django-features\/\">Explore Unique Django Features in detail<\/a><\/strong><\/p>\n<p><strong>Step 5.<\/strong> Now in the student directory, open the views.py file<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">from django.shortcuts import render\r\nfrom django.http import HttpResponse\r\ndef student_show(request):\r\n    x = []\r\n    for i in range(10):\r\n        x.append(i)\r\n    return HttpResponse(\"&lt;h1&gt;DataFlair Django Tutorials&lt;\/h1&gt;The Digits are {0}\".format(x))<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-52958\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file.png\" alt=\"Django Views - views.py file\" width=\"1322\" height=\"235\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file.png 1322w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-150x27.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-300x53.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-768x137.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-1024x182.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-1320x235.png 1320w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/views-py-file-520x92.png 520w\" sizes=\"auto, (max-width: 1322px) 100vw, 1322px\" \/><\/a><\/p>\n<p><strong>Understanding the Code:<\/strong><\/p>\n<p>Here we have imported HttpResponse from the library django.http because we need to respond in the HTTP format. Also, we are passing the parameter request to the function.<\/p>\n<p>Every view function will have their first parameter as request.<\/p>\n<p>After that, we wrote a simple python program of storing digits 0-9 in a list and we passed on that list as a string to the HttpResponse. It will then covert the same as HTTP and that will be returned to our browser as HTML which then renders it that way.<\/p>\n<p>This Views file is special as you can see, we are passing HTML as a string and that presents on the browser.<\/p>\n<p><strong>Step 6.<\/strong> To run this view simply type in the url bar, http:\/\/localhost:8000\/student\/<\/p>\n<p>Make sure to run the Django server. Now, you can imagine, with that level of integration of python with the web, you can easily play with your data in Django.<\/p>\n<p>The output of the above view should be:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-52959\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View.png\" alt=\"Django Views - Output of View\" width=\"1600\" height=\"858\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View.png 1600w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Output-of-View-520x279.png 520w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/a><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/top-django-books\/\">Check out Top Django Books for enhancing Django Development knowledge<\/a><\/strong><\/p>\n<p>If you will check the HTML in the browser then you will only see what passes as the HttpResponse in the String and not any python code.<\/p>\n<p>That\u2019s how we can generate Views in Django. This was the simplest form of View, you can actually do a lot more than writing the HTML code in the string.<\/p>\n<p>But still, this process of web development keeps the rendering output in the server file rather than on the resource server. For that, Django\u2019s 3rd component Templates is there.<\/p>\n<h2>Summary<\/h2>\n<p>Django is different from other frameworks as that there is a certain way to perform tasks in Django, The Django Way and we are learning the same in our Django Tutorials. Although sometimes <strong><a href=\"https:\/\/www.djangoproject.com\/start\/overview\/\">Django<\/a><\/strong> is criticized for its monolithic behavior but it is rather pleasant because there is a very logical way to perform activities.<\/p>\n<p>In this tutorial, we covered the concept of Django views and how we can connect and generate views in Django.<\/p>\n<p>So, now you must be cleared with the concept of Django Views. If you have any queries related to the topic, don&#8217;t hesitate to enter in the comment section. We will surely resolve it as soon as possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn about the view component of Django in detail, discuss the difference between class-based views and function-based views and the process of creating views in Django. Before starting this&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":52961,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19149],"tags":[19363,19364,19362,19365],"class_list":["post-52944","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django","tag-cbv-vs-fbv","tag-create-django-views","tag-django-views","tag-views-in-mvc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Django Views - 6 Simple Steps to Create View Component for Django Project - DataFlair<\/title>\n<meta name=\"description\" content=\"Django Views tutorial covers the description of View, difference between Class-based Views &amp; Function-based Views and steps to create Django View.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/django-views\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Django Views - 6 Simple Steps to Create View Component for Django Project - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Django Views tutorial covers the description of View, difference between Class-based Views &amp; Function-based Views and steps to create Django View.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/django-views\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-01T06:00:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-21T06:49:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Django Views - 6 Simple Steps to Create View Component for Django Project - DataFlair","description":"Django Views tutorial covers the description of View, difference between Class-based Views & Function-based Views and steps to create Django View.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/django-views\/","og_locale":"en_US","og_type":"article","og_title":"Django Views - 6 Simple Steps to Create View Component for Django Project - DataFlair","og_description":"Django Views tutorial covers the description of View, difference between Class-based Views & Function-based Views and steps to create Django View.","og_url":"https:\/\/data-flair.training\/blogs\/django-views\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-04-01T06:00:45+00:00","article_modified_time":"2021-06-21T06:49:37+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/django-views\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Django Views &#8211; 6 Simple Steps to Create View Component for Django Project","datePublished":"2019-04-01T06:00:45+00:00","dateModified":"2021-06-21T06:49:37+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/"},"wordCount":1247,"commentCount":7,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg","keywords":["CBV vs FBV","Create Django Views","Django Views","Views in MVC"],"articleSection":["Django Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/django-views\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/django-views\/","url":"https:\/\/data-flair.training\/blogs\/django-views\/","name":"Django Views - 6 Simple Steps to Create View Component for Django Project - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg","datePublished":"2019-04-01T06:00:45+00:00","dateModified":"2021-06-21T06:49:37+00:00","description":"Django Views tutorial covers the description of View, difference between Class-based Views & Function-based Views and steps to create Django View.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/django-views\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/django-views\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/django-views\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/03\/Django-Views.jpg","width":1200,"height":628,"caption":"Django Views"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/django-views\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Django Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/django\/"},{"@type":"ListItem","position":3,"name":"Django Views &#8211; 6 Simple Steps to Create View Component for Django Project"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/52944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=52944"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/52944\/revisions"}],"predecessor-version":[{"id":53824,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/52944\/revisions\/53824"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/52961"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=52944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=52944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=52944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}