<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oviyan S</title>
    <description>The latest articles on DEV Community by Oviyan S (@oviyan007).</description>
    <link>https://dev.to/oviyan007</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1451562%2F36aab4c3-5fa4-4edf-ab4e-362cd4ed753e.jpg</url>
      <title>DEV Community: Oviyan S</title>
      <link>https://dev.to/oviyan007</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oviyan007"/>
    <language>en</language>
    <item>
      <title>Mastering Django: How to Render HTML Like a Pro!</title>
      <dc:creator>Oviyan S</dc:creator>
      <pubDate>Sat, 31 Aug 2024 16:33:31 +0000</pubDate>
      <link>https://dev.to/oviyan007/mastering-django-how-to-render-html-like-a-pro-854</link>
      <guid>https://dev.to/oviyan007/mastering-django-how-to-render-html-like-a-pro-854</guid>
      <description>&lt;p&gt;Hello everyone welcome back to another interesting blog. Today we will learn how to add static files and templates to our Django web app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Static files?&lt;/strong&gt;&lt;br&gt;
Static files are nothing but in our folder with all CSS files, JS files and images required for our web app. &lt;/p&gt;

&lt;p&gt;Before that, we will learn about how to execute the Hello World in web app. Already we left with Django installation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's learn practically!!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;create the view function for displaying the Hellow world.  For that navigate to views.py and create the Python functions to return the HTTP response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

from django.shortcuts import render,HttpResponse


def home(request):
    return HttpResponse("Hello World!!!")



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything is ready now We have to map this view function to the URLs.py&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
from django.contrib import admin
from django.urls import path
from home import views 

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',views.home), 
]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the server and open it &lt;/p&gt;

&lt;p&gt;in the web browser yay!!!! we got the output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbp8xwlarhgnk2vukunx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbp8xwlarhgnk2vukunx.png" alt="output" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to render the HTML file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we know every website runs based on an HTML file our web app is also the same and for that, we have to render our template aka HTML file.&lt;/p&gt;

&lt;p&gt;Create the template folder inside the app that creates&lt;br&gt;
 the HTML file you want.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Folder Structure of App *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbiza6djfg1ncswlm18n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbiza6djfg1ncswlm18n.png" alt="file structure" width="612" height="731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;add the code to the index.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

    &amp;lt;h1&amp;gt;Yay!!!! I'm from templates&amp;lt;/h1&amp;gt;


&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Link the HTML file to the views.py All set run the server to see the output &lt;/p&gt;

&lt;p&gt;``&lt;/p&gt;

&lt;p&gt;from django.shortcuts import render,HttpResponse&lt;/p&gt;

&lt;p&gt;def home(request):&lt;br&gt;
    return render(request,"index.html")&lt;/p&gt;

&lt;p&gt;``&lt;/p&gt;

&lt;p&gt;Start the development server and open that link in the browser &lt;br&gt;
BOOM !!!!&lt;/p&gt;

&lt;p&gt;we can see the output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8bu07ghnyzba0jcbyhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8bu07ghnyzba0jcbyhv.png" alt="Image description" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connect With Me: &lt;a href="https://www.linkedin.com/in/oviyan-s/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Django's File &amp; Folder Magic: A Beginner's Guide</title>
      <dc:creator>Oviyan S</dc:creator>
      <pubDate>Tue, 20 Aug 2024 16:53:36 +0000</pubDate>
      <link>https://dev.to/oviyan007/mastering-djangos-file-folder-magic-a-beginners-guide-4880</link>
      <guid>https://dev.to/oviyan007/mastering-djangos-file-folder-magic-a-beginners-guide-4880</guid>
      <description>&lt;p&gt;Hello, &lt;strong&gt;Django Enthusiasts!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Welcome to another deep dive into Django's world. Today, we're cracking open the hood of a Django project to explore the files and folders that make it tick. Whether you're a seasoned developer or just getting started, understanding Django's project structure is key to mastering this powerful framework. Let's get started!&lt;/p&gt;

&lt;p&gt;Let's Dive into our project!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpxlmbqp2qw2i5tuubkc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpxlmbqp2qw2i5tuubkc.png" alt="Folder Structure" width="630" height="1156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating the project it creates the files which is necessary to run our Django app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;./venv&lt;/strong&gt;&lt;br&gt;
This folder is where all the files needed to run your virtual environment live. Think of it as your project's personal toolkit, ensuring everything runs smoothly.&lt;/p&gt;

&lt;p&gt;Key Files You'll Work Within Your Django Project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;settings.py:&lt;/strong&gt;&lt;br&gt;
The heart of your Django app. It’s where all the configuration happens, making sure your app runs just the way you want it to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;urls.py:&lt;/strong&gt;&lt;br&gt;
This is the map of your app. It defines the routes, telling Django which pages to serve when someone visits a specific URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inside Each App:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;migrations directory:&lt;/strong&gt;&lt;br&gt;
This folder keeps track of all your database changes. Every time you tweak your models, this is where the history is stored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;admin.py:&lt;/strong&gt;&lt;br&gt;
Here’s where you connect your models to Django's admin interface. It’s your backstage pass to manage your app’s data easily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;models.py:&lt;/strong&gt;&lt;br&gt;
This is where you define your database structure. If your app needs to store data, you’ll be writing the blueprint for it here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;views.py:&lt;/strong&gt;&lt;br&gt;
The brain of your app. This file is where you’ll write the logic that powers your app, from handling user requests to rendering the right templates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;manage.py:&lt;/strong&gt;&lt;br&gt;
The unsung hero of your Django project. Without this file, you can’t run your app. It’s like the manager coordinating all the different parts of your project.&lt;/p&gt;

&lt;p&gt;comment "Django" for the next part&lt;/p&gt;

&lt;p&gt;connect with me&lt;a href="https://www.linkedin.com/in/oviyan-s/" rel="noopener noreferrer"&gt; Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Launch Your First Django App Like a Pro 🚀</title>
      <dc:creator>Oviyan S</dc:creator>
      <pubDate>Sat, 17 Aug 2024 16:39:02 +0000</pubDate>
      <link>https://dev.to/oviyan007/launch-your-first-django-app-like-a-pro-3h5n</link>
      <guid>https://dev.to/oviyan007/launch-your-first-django-app-like-a-pro-3h5n</guid>
      <description>&lt;p&gt;Have you ever created Web Applications? &lt;/p&gt;

&lt;p&gt;Don't worry if not I will teach you how to create the web application using Django.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Django?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python-based web framework Django allows you to create efficient web applications quickly. It is also called batteries included web framework Django because It provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6qnv13nbghguvioxvap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6qnv13nbghguvioxvap.png" alt="Django Benefits &amp;amp; features" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets Learn Practically!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before get into create the folder then open the folder in vscode or in your favourite browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated Python virtual environments for them. This is one of the most important tools that most Python developers use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Create Virtual Environment&lt;/strong&gt;&lt;br&gt;
To create Virtual Environment Run following command in your terminal &lt;br&gt;
&lt;code&gt;python -m venv .venv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;it will create the folder venv&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2jucgwobm9vtmxbjjog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2jucgwobm9vtmxbjjog.png" alt="Venv Folder Structure" width="620" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run the virtual Environment&lt;/strong&gt;&lt;br&gt;
To run the virtual environment run following command&lt;br&gt;
 &lt;code&gt;.venv\Scripts\activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install the Necessary Libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we need the Django library to create the Django App so install the Django libraries by run the following command&lt;br&gt;
&lt;code&gt;pip install django&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create the Project&lt;/strong&gt;&lt;br&gt;
Django needs a project within the project our necessary codes are there&lt;br&gt;
and it need Apps&lt;br&gt;
To create project run following command&lt;br&gt;
&lt;code&gt;django-admin startproject example .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, the example is the name of the project and represents creating a project within the folder if we didn't mention it. it creates a subfolder with the same project name.&lt;/p&gt;

&lt;p&gt;After Running the command it creates some of the files for our django project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff28pluy2gb76sgjvm049.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff28pluy2gb76sgjvm049.png" alt="Folder Structure of the Project" width="550" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create App&lt;/strong&gt; &lt;br&gt;
A project has many app for many features of the web applications For example if we web Application in our app has login for that we create separate app.&lt;/p&gt;

&lt;p&gt;To Create App Run following command &lt;br&gt;
&lt;code&gt;django-admin startapp home&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;it create folder name Home within the folder it has few files which is the necessary file to run our App&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0pjq63ok2pw0lq5thr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0pjq63ok2pw0lq5thr0.png" alt="Folder Structure of the App" width="589" height="1138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add our App Name in the Setting.py&lt;/strong&gt;&lt;br&gt;
Setting.py is main file required to run our webapp in that file contains configurations of our app.&lt;/p&gt;

&lt;p&gt;now we add our app in the settings.py file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9omp6xyuep06q3nl9yr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9omp6xyuep06q3nl9yr.png" alt="Setting.py " width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run Our WebApp&lt;/strong&gt;&lt;br&gt;
All set we can run our app using the development server django has the inbuilt developement server.&lt;/p&gt;

&lt;p&gt;To start Developement server Run the Following command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python manage.py runserver&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Yayy!!!!&lt;/p&gt;

&lt;p&gt;Now we can see our app on &lt;a href="http://127.0.0.1:8000/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0ik85yjs4wkg3lfiff6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0ik85yjs4wkg3lfiff6.png" alt="output of the app" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you got above output you successfully Run the Django App.&lt;/p&gt;

&lt;p&gt;Linkedin-&lt;a href="https://linkedin.com/in/oviyan-s" rel="noopener noreferrer"&gt;Connect with me&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comment "Django" for the next part&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>python</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
