How to use annotate aggregation in django

Hello World, Welcome to Today we will discuss how to use annotate aggregation in Django. In this tutorial, we will fetch data from two different models. For example, I am creating a video sharing website like YouTube. I have two models. One is a channel and another is a video. Both models are joined with foreign keys. Now I want to fetch channels with videos count. I will do this with annotate aggregation.

Continue reading


Create class based view in django 3

Hello World, Welcome to projects Today we will learn how to create a class-based view in Django 3. In this tutorial, we will render a simple template via class. Basically, there are two methods to load the view template in Django. One is a function-based view(FBV) and another is a class-based view(CBV). Class-based views were introduced in Django 1.7. The reason behind this was the proper structure, inheritance and the developer can customize the class-based view more than the function-based view.

  • Create cbv.html in the templates folder in your app and add the following code.
  • <!DOCTYPE html>
    <html lang="en">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>CBV View</title>
        <h3>Hello World, This is class based view</h3>


  • Open app/ and add the following code in it
  • urlpatterns=[


Python example 3 – Solver number power

Hello World, Welcome to In this example, we will calculate the power of the number. We will take the number and power from the user and calculate it with python function. We will do this in the following steps.

  • define power_multiply function
  • get to input from the user number and power
  • calculate the number of power with ** expression
def power_multiply():
    number=int(input('Enter the number '))
    power=int(input('Enter the power '))

Output of this example



Create comment system with jquery ajax and laravel 7

Hello World, Welcome to Today we will learn how to create a comment system with jQuery Ajax and Laravel 7. In this tutorial, we will save comments and show instantly with the total comments count. This gonna be a very interesting tutorial for me as well as for you (I hope). I have divided this tutorial into the following parts:

  • Create a Post model
  • Create a Comment model
  • Define the hasMany relationship in Post Model
  • Add dummy data for post
  • Create a PostController and define a method for post list and post detail
  • Create templates for post and post detail with comments and show data
  • Setup route
  • Add a comment with jquery ajax and  show instantly

Continue reading

Count page views in laravel 7

Hello World, Today we will learn how to count page views in Laravel 7. In this tutorial, we simply count the page views whenever the user visits the page. Suppose we have a post detail page and we want to show how many times this post has been viewed by users. We will use shorthand Laravel query methods to solve this problem.


The above method will increase 1 every time. If you want to increase 2 or more then you can change the above code as follows.




Fetch data with model relationship in laravel 7

Hello World, Welcome to Today we will discuss how we can fetch data with the model relationship in laravel 7. In this tutorial, we will create an example of hasMany and belongsTo model relationship.

hasMany Relationship

Suppose you have a blog website and you want to fetch comments of a specific post on the post detail page. In this scenario, you should have two models, Post and Comment respectively. We know that a single post has many comments so we will define the hasMany relationship in the post model.

Continue reading


Python Example 2 – Summing Numbers

Hello World, Welcome to In this tutorial, we will create a custom python function to show the sum of the provided numbers. This function takes a sequence of numbers and shows the sum of those numbers. This exercise helps you to understand numbers and function design.

Continue reading


Python Example 1 – Number guessing game with python

Hello World, Welcome to Today we will discuss how to create a number guessing game with python. This tutorial is for python beginner. Python has three different numeric types: int, float, and complex. Most of the time, it is enough to know about int(for the whole number) and float(for fraction number). For this game, we will do the following steps

  • Write a function guess_number that takes no arguments.
  • When we run this function it will automatically choose the number between 0-50.
  • Ask the user to guess what number has been chosen.
  • Every time user guess a number, we will indicate the following:
    • Too High
    • Too Low
    • Just Right
  • If the user guesses the correct number then the program exit, otherwise the user is asked to try again.
  • Programm will exist only if the user guesses the correct number.

Continue reading