<?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: Abdulla Fajal</title>
    <description>The latest articles on DEV Community by Abdulla Fajal (@abdullafajal).</description>
    <link>https://dev.to/abdullafajal</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%2F1050824%2F96850e88-715c-4aae-8abd-11cdc782fbd5.jpg</url>
      <title>DEV Community: Abdulla Fajal</title>
      <link>https://dev.to/abdullafajal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdullafajal"/>
    <language>en</language>
    <item>
      <title>Implement Form Validation in HTML CSS and JavaScript</title>
      <dc:creator>Abdulla Fajal</dc:creator>
      <pubDate>Fri, 26 May 2023 10:47:05 +0000</pubDate>
      <link>https://dev.to/abdullafajal/implement-form-validation-in-html-css-and-javascript-4ole</link>
      <guid>https://dev.to/abdullafajal/implement-form-validation-in-html-css-and-javascript-4ole</guid>
      <description>&lt;p&gt;Form validation is a crucial aspect of web development that ensures user-submitted data is accurate, complete, and in the expected format. We can enhance the user experience, improve data integrity, and prevent potential errors or security vulnerabilities by validating form inputs before processing them.&lt;/p&gt;

&lt;p&gt;This article will explore how to implement form validation using HTML, CSS, and JavaScript. We’ll cover the essential techniques and demonstrate practical examples you can apply to your web projects. Let’s dive in!&lt;/p&gt;

&lt;p&gt;HTML Structure:&lt;br&gt;
To begin with, let’s set up the HTML structure for our form. We’ll create a simple form that collects user information, such as name, email, and password. Open your favourite text editor and create a new HTML file, then enter the following code:&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 http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;!-- Fontawesome CDN Link For Icons --&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" /&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
    &amp;lt;title&amp;gt;Form Validation | Espere.in&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form action="#"&amp;gt;
        &amp;lt;h2&amp;gt;Signup Form&amp;lt;/h2&amp;gt;
        &amp;lt;div class="form-group fullname"&amp;gt;
          &amp;lt;label for="fullname"&amp;gt;Full Name&amp;lt;/label&amp;gt;
          &amp;lt;input type="text" id="fullname" placeholder="Enter your full name"&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="form-group email"&amp;gt;
          &amp;lt;label for="email"&amp;gt;Email Address&amp;lt;/label&amp;gt;
          &amp;lt;input type="text" id="email" placeholder="Enter your email address"&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="form-group password"&amp;gt;
          &amp;lt;label for="password"&amp;gt;Password&amp;lt;/label&amp;gt;
          &amp;lt;input type="password" id="password" placeholder="Enter your password"&amp;gt;
          &amp;lt;i id="pass-toggle-btn" class="fa-solid fa-eye"&amp;gt;&amp;lt;/i&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="form-group date"&amp;gt;
          &amp;lt;label for="date"&amp;gt;Birth Date&amp;lt;/label&amp;gt;
          &amp;lt;input type="date" id="date" placeholder="Select your date"&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="form-group gender"&amp;gt;
          &amp;lt;label for="gender"&amp;gt;Gender&amp;lt;/label&amp;gt;
          &amp;lt;select id="gender"&amp;gt;
            &amp;lt;option value="" selected disabled&amp;gt;Select your gender&amp;lt;/option&amp;gt;
            &amp;lt;option value="Male"&amp;gt;Male&amp;lt;/option&amp;gt;
            &amp;lt;option value="Female"&amp;gt;Female&amp;lt;/option&amp;gt;
            &amp;lt;option value="Other"&amp;gt;Other&amp;lt;/option&amp;gt;
          &amp;lt;/select&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="form-group submit-btn"&amp;gt;
          &amp;lt;input type="submit" value="Submit"&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/form&amp;gt;
      &amp;lt;!-- JavaScript code --&amp;gt;
      &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section includes the HTML doctype declaration &amp;lt;!DOCTYPE html&amp;gt;. It also sets the language of the document to English using the lang attribute in the  tag.&lt;/p&gt;

&lt;p&gt;In the &lt;/p&gt; section, various meta tags are included for character encoding, compatibility, and viewport settings.

&lt;p&gt;Additionally, there are two  tags. The first link is for the Font Awesome CDN (Content Delivery Network), which provides icons for the form. The second link is for an external CSS file named style.css.&lt;/p&gt;


&lt;p&gt;Inside the &lt;/p&gt; tag, there is a  element. The form has various form fields for users to input their information.


&lt;p&gt;The &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; heading displays the title of the form as "Signup Form".&lt;br&gt;&lt;br&gt;
Each form field is enclosed in a &lt;/p&gt; element with a specific class (form-group) for styling purposes.&lt;br&gt;&lt;br&gt;
The form fields include:&lt;br&gt;&lt;br&gt;
Full Name: A text input field with the id “fullname” and a placeholder text “Enter your full name”.&lt;br&gt;&lt;br&gt;
Email Address: A text input field with the id “email” and a placeholder text “Enter your email address”.&lt;br&gt;&lt;br&gt;
Password: A password input field with the id “password” and a placeholder text “Enter your password”. There is also an eye icon provided by Font Awesome (fa-eye) to toggle password visibility.&lt;br&gt;&lt;br&gt;
Birth Date: A date input field with the id “date” and a placeholder text “Select your date”.&lt;br&gt;&lt;br&gt;
Gender: A select dropdown with the id “gender” and options for selecting the gender.&lt;br&gt;&lt;br&gt;
Finally, there is a submit button with the text “Submit”.&lt;br&gt;&lt;br&gt;
At the end of the HTML file, there is a  tag that references an external JavaScript file named script.js. This is where you would write the JavaScript code to handle form validation and other functionality.&amp;lt;/p&amp;gt;

&lt;p&gt;&amp;lt;p&amp;gt;In the next part, we’ll continue with the CSS styling and move on to implementing the JavaScript code for form validation.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;Please let me know if you would like to continue with the rest of the article or if there’s anything specific you’d like to learn about form validation.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;CSS Styling:&amp;lt;br&amp;gt;&lt;br&gt;
Now that we have set up the HTML structure, let’s proceed with styling the form using CSS. Open the styles.css file and add the following CSS code:&amp;lt;br&amp;gt;&lt;br&gt;
&amp;lt;/p&amp;gt;&lt;br&gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;@import url('&lt;a href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&amp;amp;amp;display=swap'"&gt;https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&amp;amp;amp;amp;display=swap'&lt;/a&gt;);&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
padding: 0 10px;
min-height: 100vh;
background: #2C7873;
}
form {
padding: 25px;
background: #fff;
max-width: 500px;
width: 100%;
border-radius: 7px;
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.05);
}
form h2 {
font-size: 27px;
text-align: center;
margin: 0px 0 30px;
}
form .form-group {
margin-bottom: 15px;
position: relative;
}
form label {
display: block;
font-size: 15px;
margin-bottom: 7px;
}
form input,
form select {
height: 45px;
padding: 10px;
width: 100%;
font-size: 15px;
outline: none;
background: #fff;
border-radius: 3px;
border: 1px solid #bfbfbf;
}
form input:focus,
form select:focus {
border-color: #9a9a9a;
}
form input.error,
form select.error {
border-color: #f91919;
background: #f9f0f1;
}
form small {
font-size: 14px;
margin-top: 5px;
display: block;
color: #f91919;
}
form .password i {
position: absolute;
right: 0px;
height: 45px;
top: 28px;
font-size: 13px;
line-height: 45px;
width: 45px;
cursor: pointer;
color: #939393;
text-align: center;
}
.submit-btn {
margin-top: 30px;
}
.submit-btn input {
color: white;
border: none;
height: auto;
font-size: 16px;
padding: 13px 0;
border-radius: 5px;
cursor: pointer;
font-weight: 500;
text-align: center;
background: #2C7873;
transition: 0.2s ease;
}
.submit-btn input:hover {
background: #40ada6;
}
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;lt;p&amp;gt;The CSS code begins with an @import statement that imports the &amp;amp;#39;Open Sans&amp;amp;#39; font from Google Fonts. This font will be used for the entire document.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;The * selector applies the following styles to all elements on the page:&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;margin: 0; and padding: 0; set the margin and padding of all elements to zero, effectively removing any default spacing.&amp;lt;br&amp;gt;&lt;br&gt;
box-sizing: border-box; ensures that the total width and height of an element includes the padding and border, rather than being added on top of it. This prevents the element from expanding beyond its intended size.&amp;lt;br&amp;gt;&lt;br&gt;
font-family: &amp;amp;#39;Open Sans&amp;amp;#39;, sans-serif; sets the font family for all elements to &amp;amp;#39;Open Sans&amp;amp;#39;, a sans-serif font. If &amp;amp;#39;Open Sans&amp;amp;#39; is not available, it falls back to the default sans-serif font.&amp;lt;br&amp;gt;&lt;br&gt;
The body selector applies styles to the &amp;lt;body&amp;gt; element:&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;display: flex; creates a flex container, allowing its child elements to be aligned and positioned using a flexbox.&amp;lt;br&amp;gt;&lt;br&gt;
align-items: center; and justify-content: center; center the content horizontally and vertically within the flex container.&amp;lt;br&amp;gt;&lt;br&gt;
padding: 0 10px; sets a left and right padding of 10 pixels for the body content.&amp;lt;br&amp;gt;&lt;br&gt;
min-height: 100vh; sets the minimum height of the body to 100% of the viewport height, ensuring that the content fills the screen.&amp;lt;br&amp;gt;&lt;br&gt;
background: #2C7873; sets the background color of the body to a shade of green.&amp;lt;br&amp;gt;&lt;br&gt;
The form selector applies styles to the &amp;lt;form&amp;gt; element:&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;padding: 25px; adds padding around the form content.&amp;lt;br&amp;gt;&lt;br&gt;
background: #fff; sets the background color of the form to white.&amp;lt;br&amp;gt;&lt;br&gt;
max-width: 500px; sets the maximum width of the form to 500 pixels.&amp;lt;br&amp;gt;&lt;br&gt;
width: 100%; ensures that the form takes up the full width of its container.&amp;lt;br&amp;gt;&lt;br&gt;
border-radius: 7px; rounds the corners of the form, giving it a slightly curved appearance.&amp;lt;br&amp;gt;&lt;br&gt;
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.05); adds a subtle box shadow to the form, giving it a 3D effect.&amp;lt;br&amp;gt;&lt;br&gt;
The form h2 selector applies styles to the &amp;lt;h2&amp;gt; element within the form:&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;font-size: 27px; sets the font size of the heading to 27 pixels.&amp;lt;br&amp;gt;&lt;br&gt;
text-align: center; centers the text horizontally within the heading.&amp;lt;br&amp;gt;&lt;br&gt;
margin: 0px 0 30px; sets the margin of the heading, with no top margin, no left or right margin, and a bottom margin of 30 pixels.&amp;lt;br&amp;gt;&lt;br&gt;
The form .form-group selector applies styles to the &amp;lt;div&amp;gt; elements with the class &amp;amp;quot;form-group&amp;amp;quot; within the form:&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;margin-bottom: 15px; adds a margin at the bottom of each form group, creating vertical spacing between them.&amp;lt;br&amp;gt;&lt;br&gt;
position: relative; sets the position of the form group as relative, allowing the absolute positioning of child elements within it.&amp;lt;br&amp;gt;&lt;br&gt;
The code snippet continues with more CSS styles for different form elements and classes, such as labels, inputs, error states, submit buttons etc.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;With these CSS styles, our form will have a clean and visually appealing layout. Feel free to modify the styles to match your preferences or the overall design of your website.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;JavaScript Validation:&amp;lt;br&amp;gt;&lt;br&gt;
Now, let’s move on to implementing the JavaScript code for form validation.&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;To read more full articles click here👇&amp;lt;/p&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;p&amp;gt;&amp;lt;a href="&lt;a href="https://espere.in/Implement-Form-Validation-in-HTML-CSS-and-JavaScript/%22&amp;gt;https://espere.in/Implement-Form-Validation-in-HTML-CSS-and-JavaScript/&amp;lt;/a&amp;gt;&amp;lt;/p"&gt;https://espere.in/Implement-Form-Validation-in-HTML-CSS-and-JavaScript/"&amp;amp;gt;https://espere.in/Implement-Form-Validation-in-HTML-CSS-and-JavaScript/&amp;amp;lt;/a&amp;amp;gt;&amp;amp;lt;/p&lt;/a&gt;&amp;gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>WhatsApp login in Django Application using OPT-less</title>
      <dc:creator>Abdulla Fajal</dc:creator>
      <pubDate>Thu, 11 May 2023 13:17:28 +0000</pubDate>
      <link>https://dev.to/abdullafajal/whatsapp-login-in-django-application-using-opt-less-4p4a</link>
      <guid>https://dev.to/abdullafajal/whatsapp-login-in-django-application-using-opt-less-4p4a</guid>
      <description>&lt;p&gt;Liquid syntax error: Unknown tag 'static'&lt;/p&gt;
</description>
    </item>
    <item>
      <title>How to create a translate project with Django</title>
      <dc:creator>Abdulla Fajal</dc:creator>
      <pubDate>Tue, 09 May 2023 06:11:25 +0000</pubDate>
      <link>https://dev.to/abdullafajal/how-to-create-a-translate-project-with-django-hl0</link>
      <guid>https://dev.to/abdullafajal/how-to-create-a-translate-project-with-django-hl0</guid>
      <description>&lt;p&gt;This article will create a translator app using Django, Django is a popular Python web framework. This app will allow users to input text in one language and receive a translation in another language. We will be using the translate python package to do the translation. If you want to learn Python and Django, then our courses are available, you can see them. Let us begin without wasting your time at all.&lt;/p&gt;

&lt;p&gt;I think Django will be already installed in your system If not then you can install it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install django
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And Install the translate package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install translate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's create our project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject translator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A project named movie will be created, you can do cd movie and go inside it.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You have to create an app, you can give any name to the project and app, we have given it the name of app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py startapp app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have to mention this app in your project setting in INSTALLED_APPS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "app", # new
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create views that handle the translation. Now we need to create a view that will handle the translation. Open up app/views.py and add the following code:&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
from translate import Translator

# Create your views here.


def home(request):
    if request.method == "POST":
        text = request.POST["translate"]
        to_lang = request.POST["tolanguage"]
        from_lang = request.POST["fromlanguage"]
        translator = Translator(to_lang=to_lang, from_lang=from_lang)
        translation = translator.translate(text)

        context = {
            "translation": translation,
        }
        return render(request, "home.html", context)
    return render(request, "home.html")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code defines a view function called home() which is associated with the route for the homepage ("/") in a Django web application.&lt;/p&gt;

&lt;p&gt;The function starts by checking the request method. If the request method is "POST", the function extracts data from the form submitted through the POST method. The text variable contains the text entered in the form, the to_lang variable contains the target language selected in the form and the from_lang variable contains the source language selected in the form.&lt;br&gt;
A new instance of the Translator class from the translate module is then created, passing in the to_lang and from_lang variables as parameters. The translate() method of the Translator instance is then called with text as the argument to translate the text. The translated text is then stored in the translation variable.&lt;/p&gt;

&lt;p&gt;Finally, a dictionary named context is created, which contains the translated text as a value associated with the key "translation". The home() function then renders the "home.html" template, passing in the context dictionary as a context variable.&lt;/p&gt;

&lt;p&gt;If the request method is not "POST", the function simply renders the "home.html" template without any context variable.&lt;/p&gt;

&lt;p&gt;We have to create the template mentioned in the views, and for that, we have to create a directory named templates inside our app, in that, we will write the code of the template.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://espere.in/How-to-create-a-translate-project-with-Django/"&gt;Read More Here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>translate</category>
      <category>python</category>
    </item>
    <item>
      <title>Mastering Control Flow: A Beginner's Guide to Python Loops</title>
      <dc:creator>Abdulla Fajal</dc:creator>
      <pubDate>Fri, 24 Mar 2023 11:31:08 +0000</pubDate>
      <link>https://dev.to/abdullafajal/mastering-control-flow-a-beginners-guide-to-python-loops-34mi</link>
      <guid>https://dev.to/abdullafajal/mastering-control-flow-a-beginners-guide-to-python-loops-34mi</guid>
      <description>&lt;p&gt;Control flow is a fundamental concept in programming that allows developers to control the order of execution of statements in their code. In Python, there are several constructs that allow you to implement control flow, with loops being one of the most commonly used. In this beginner’s guide to Python loops, we will explore how to use loops to iterate over sequences, perform repeated actions, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Loops?
&lt;/h2&gt;

&lt;p&gt;Loops are constructs in programming that allow you to repeat a set of instructions multiple times. In Python, there are two types of loops: for loops and while loops. Both loops allow you to execute a block of code repeatedly, but they differ in how they control the number of iterations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The for Loop
&lt;/h2&gt;

&lt;p&gt;The for loop is used to iterate over a sequence of items. A sequence can be any collection of items, including lists, tuples, and strings. The basic syntax of a for loop is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for item in sequence:
    # do something with item
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The for loop starts by initializing a variable item to the first item in the sequence. It then executes the block of code inside the loop, which can access the current value of item and perform some action on it. After the block of code is executed, the loop moves on to the next item in the sequence and repeats the process until all items have been processed.&lt;/p&gt;

&lt;p&gt;Let’s look at an example of a for loop that iterates over a list of numbers and prints out each number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4, 5]
for number in numbers:
    print(number)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
3
4
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the for loop iterates over the list of numbers, and for each number, it prints out the value of the variable number. The loop continues until all items in the list have been processed.&lt;/p&gt;

&lt;p&gt;The range() Function&lt;/p&gt;

&lt;p&gt;In some cases, you may need to execute a block of code a specific number of times, rather than iterating over a sequence of items. In such cases, you can use the range() function to generate a sequence of numbers that can be used in a for loop.The range() function takes one, two, or three arguments, depending on how you want to use it. The basic syntax is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;range(stop)
range(start, stop)
range(start, stop, step)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The range() function generates a sequence of numbers that starts at start, ends at stop (exclusive), and increments by step (default is 1). Here are some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# generate a sequence of numbers from 0 to 4 (exclusive)
for i in range(5):
    print(i)
# generate a sequence of numbers from 2 to 5 (exclusive)
for i in range(2, 5):
    print(i)
# generate a sequence of numbers from 0 to 10 (exclusive), incrementing by 2
for i in range(0, 10, 2):
    print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
1
2
3
4
2
3
4
0
2
4
6
8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The while Loop
&lt;/h2&gt;

&lt;p&gt;The while loop is used to execute a block of code repeatedly as long as a certain condition is true. The basic syntax of a while loop is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while condition:
    # do something
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The while loop starts by checking the condition. If the condition is true, the loop executes the block of code inside it. After the block of code is executed, the condition is checked again. If it is still true, the block of code is executed again, and the process repeats until the condition becomes false.&lt;/p&gt;

&lt;p&gt;Let’s look at an example of a while loop that counts down from 5 to 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count = 5
while count &amp;gt; 0:
    print(count)
    count -= 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5
4
3
2
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the while loop executes as long as the value of count is greater than 0. Each time the loop iterates, it prints the current value of count and subtracts 1 from it, until count becomes 0 and the loop exits.&lt;/p&gt;

&lt;p&gt;For Read More Click Here &lt;a href="https://espere.in/Mastering-Control-Flow:-A-Beginner's-Guide-to-Python-Loops/"&gt;Espere.in&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>django</category>
      <category>loop</category>
    </item>
    <item>
      <title>10 Django Built-in Views You Need to Know for Your Next Project</title>
      <dc:creator>Abdulla Fajal</dc:creator>
      <pubDate>Thu, 23 Mar 2023 08:35:58 +0000</pubDate>
      <link>https://dev.to/abdullafajal/10-django-built-in-views-you-need-to-know-for-your-next-project-1p6c</link>
      <guid>https://dev.to/abdullafajal/10-django-built-in-views-you-need-to-know-for-your-next-project-1p6c</guid>
      <description>&lt;p&gt;Django is a powerful web framework for building web applications quickly and efficiently. It includes many built-in views that can be used to handle common tasks such as displaying a list of objects, creating new objects, and editing existing objects. In this answer, I will cover 10 Django built-in views that you should know for your next project, along with proper explanations and examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  ListView
&lt;/h2&gt;

&lt;p&gt;ListView The ListView is a built-in view that displays a list of objects from a model. It is commonly used to display a list of blog posts, products, or other types of content. Here's an example:&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.views.generic import ListView
from .models import Post

class PostListView(ListView):
    model = Post
    template_name = 'blog/post_list.html'
    context_object_name = 'posts'
    ordering = ['-date_posted']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the ListView is used to display a list of blog posts from the Post model. The template_name attribute specifies the template to use for rendering the view, and the context_object_name attribute specifies the name of the context variable that will contain the list of objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  DetailView
&lt;/h2&gt;

&lt;p&gt;DetailView The DetailView is a built-in view that displays the details of a single object from a model. It is commonly used to display a blog post, product details, or other types of content. Here's an example:&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.views.generic import DetailView
from .models import Post

class PostDetailView(DetailView):
    model = Post
    template_name = 'blog/post_detail.html'
    context_object_name = 'post'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, DetailView is used to display the details of a single blog post from the Post model. The template_name attribute specifies the template to use for rendering the view, and the context_object_name attribute specifies the name of the context variable that will contain the object.&lt;/p&gt;

&lt;h2&gt;
  
  
  CreateView
&lt;/h2&gt;

&lt;p&gt;CreateView The CreateView is a built-in view that displays a form to create a new object from a model. It is commonly used to create new blog posts, products, or other types of content. Here's an example:&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.views.generic import CreateView
from .models import Post
from .forms import PostForm

class PostCreateView(CreateView):
    model = Post
    form_class = PostForm
    template_name = 'blog/post_form.html'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the CreateView is used to display a form to create a new blog post from the Post model. The form_class attribute specifies the form to use for rendering the form, and the template_name attribute specifies the template to use for rendering the view.&lt;/p&gt;

&lt;h2&gt;
  
  
  UpdateView
&lt;/h2&gt;

&lt;p&gt;UpdateView The UpdateView is a built-in view that displays a form to edit an existing object from a model. It is commonly used to edit blog posts, products, or other types of content. Here's an example:&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.views.generic import UpdateView
from .models import Post
from .forms import PostForm

class PostUpdateView(UpdateView):
    model = Post
    form_class = PostForm
    template_name = 'blog/post_form.html'

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

&lt;/div&gt;



&lt;p&gt;In this example, the UpdateView is used to display a form to edit an existing blog post from the Post model. The form_class attribute specifies the form to use for rendering the form, and the template_name attribute specifies the template to use for rendering the view.&lt;/p&gt;

&lt;h2&gt;
  
  
  DeleteView
&lt;/h2&gt;

&lt;p&gt;DeleteView The DeleteView is a built-in view that displays a confirmation page before deleting an object from a model. It is commonly used to delete blog posts, products, or other types of content. Here's an example:&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.views.generic import DeleteView
from .models import Post
from django.urls import reverse_lazy

class PostDeleteView(DeleteView):
    model = Post
    template_name = 'blog/post_confirm_delete.html'
    success_url = reverse_lazy('blog-home')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the DeleteView is used to display a confirmation page before deleting a blog post from the Post model. The template_name attribute specifies the template to use for rendering the view, and the success_url attribute specifies the URL to redirect to after the object is deleted.&lt;/p&gt;

&lt;h2&gt;
  
  
  FormView
&lt;/h2&gt;

&lt;p&gt;FormView The FormView is a built-in view that displays a form and processes user input. It can be used to implement custom forms or handle form submissions. Here's an example:&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.views.generic import FormView
from .forms import ContactForm
from django.urls import reverse_lazy

class ContactView(FormView):
    form_class = ContactForm
    template_name = 'contact.html'
    success_url = reverse_lazy('contact-success')

    def form_valid(self, form):
        form.send_email()
        return super().form_valid(form)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the FormView is used to display a contact form and send an email when the form is submitted. The form_class attribute specifies the form to use for rendering the form, and the template_name attribute specifies the template to use for rendering the view. The success_url attribute specifies the URL to redirect to after the form is successfully submitted. The form_valid() method is overridden to send the email when the form is submitted.&lt;/p&gt;

&lt;p&gt;For Read More Click Here &lt;a href="https://espere.in/10-Django-Built-in-Views-You-Need-to-Know-for-Your-Next-Project/"&gt;Espere.in&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
    </item>
  </channel>
</rss>
