Python working with inheritance - oop's

Python working with inheritance - oop's
Inheritance in python defined as acquiring the properties from the parent/base class to its child classes. In reality we develop complex applications that provides more utilities to users. In developer perspective each utility involves different modules which work together to provide an utility to the user. Each module involves many functions and c

Read more

how to add custom views to django admin

how to add custom views to django admin
how to add custom views to django admin without actually creating the database table ? Let's talk about it. In django admin to get the url link in the admin we have to register the model but in some cases we just need the a url with some functionality under an applicaiton. We can implement it with a simple trick. To implement it we have to create a

Read more

Python method overloading

Python method overloading
method overloading in python can be defined as writing the method in such a way that method will provide different functionality for different datatype arguments with the same method name. Programming languages like Java and C++ implements the method overloading by defining the two methods with the same name but different parameters. In python we d

Read more

'__enter__' and '__exit__' context managers in python

'__enter__' and '__exit__' context managers in python
__enter__ and __exit__ are built in methods in python. __enter__ and __exit__ methods are also called as context manager special methods in python. You may come up with the question "what is a context manager ?". A context manager is a manager which has the ability to make avail the data withing the context or within a block of code and destroy it

Read more

model serializers in Django Rest Framework

model serializers in Django Rest Framework
Model serializers in django rest framework are very similar to the django model forms. By using the model serializers we can reduce the effort of writing the more code for serializers. Model serializers are the shortcuts that allow us to automatically create a serializer with fields that associated with the resective model. Model serializer class i

Read more

Python object oriented programming

Python object oriented programming
Object oriented programming is one of the programming approaches in solving the problems with progamming. Python supports object oriented programming(OOP) approach. While using OOP's in python we mostly use terms like object, class, method, etc. Some of the principles of Object Oriented Programming class object method inheritance polymorphism data

Read more

working with select_related in django

working with select_related in django
select_related is a queryset method in Django which returns new queryset result for a Django Model. select_related is more helpful in foreign-key relationships. It is useful when we are going to use those foreign-key relationship data later in our code. select_related is a preformance booster, which caches the result for the foreign-key relationshi

Read more

using custom widgets in django

using custom widgets in django
In Django we use built-in forms. After rendering the template with form and form fields we can see the equivalent html is generated from the form fields. How Django is doing that ? Well, to generate HTML from the form fields django uses form Widgets. In some cases we need the some specific HTML format from Django widgets. In such cases we write our

Read more

Allow remote connections to PostgreSQL

Allow remote connections to PostgreSQL
Working with the PostgreSQL in server is fine. But, sometimes we need to access the server or cloud database from our local machine. But, when we try to connect to the PostgresSQL server database from local it will not connect. Because, by the default configuration PostgreSQL only allows host "localhost" or "12.0.0.1". To allow remote connections t

Read more

serializers in Django Rest Framework

serializers in Django Rest Framework
Serializers in django rest framework are similar to django forms. By using django rest framework serializers we can serialize and deserialize the data. We can also validate the incoming data using django rest framework serializers to maintain the integrity of the data. We can divide the django rest framework serializers into two categories. Normal

Read more

how to add swap memory in ubuntu

how to add swap memory in ubuntu
In every computer we have a physical memory(i.e: RAM). When a user starts a program it is loaded from the disk (where the program resides) to the RAM, because RAM is faster than the disk memory. Some processes intially need more memory to startup but after it will not use the complete memory that is allocated to it. When RAM is completely used then

Read more

working with supervisor on ubuntu

working with supervisor on ubuntu
In most of the ubuntu virtual private servers it is often case that we will have to run several small programs continuously. The most traditional way to do it is to write a init script in for the program that we want to run continuously. But it is a time consuming process to manage it. Supervisor is a process manager which manages the long running

Read more

django static files usage

django static files usage
Every website needs to serve the extra files such as images, CSS, JavaScript. The name "static" itself indicates that contents of files do not change. So, in django to work with static files we need to make some configurations in setttings.py file.

Read more

how to use templates in django

how to use templates in django
Django is a webframework so, It needs to maintain the code in such a way that it should be easy to navigate and easy to read and maintain. As we already know the Django framework is a MVC, we do not write the HTML code in the views.py instead we write it in a template. In django web framework we generate dynamic HTTP response. While generating the

Read more

usage of group_by and string_agg in django, postgreSQL

usage of group_by and string_agg in django, postgreSQL
In this article we are going to learn how to optimize the queries in Django applications. Django has a built-in ORM which converts the django query into optimized SQL query. In some cases we need to group the data based on some common django field or a table column. This can also be done without using the group_by and string_agg in django query. In

Read more

getting started with Django Rest Framework

getting started with Django Rest Framework
Before we get started with django rest framework we need to have the basic knowledge of python, django and how to work with RESTful API's. Django Rest Framework was developed by Tom Christe. It is one of the worlds leading API development frameworks. Django REST Framework is a open-source software and it is used by worlds best companies including M

Read more

Introduction to RESTful api's

Introduction to RESTful api's
REST(Representational state transfer) is a one of the architectural(designed with some specific rules and regulations) ways to transfer the data by using the HTTP protocol. In this article we will learn what are the restful api's and why we use it.we'll understand api request format and request methods in REST api's and it's usage. Why we use REST

Read more

how to upload python package to pypi

how to upload python package to pypi
Python is a opensource programming language. It's very easy to learn and use. It is used in many areas like web development, game development, network programming, scientific and numeric computing and more. Python's license is administered by the Python Software Foundation. As it is a opensource so many developers are writing their own packages for

Read more

getting started with django first app

getting started with django first app
Let's get started with our very first django application. I always recommend newbies to use the latest versions of django and python. Python2.X.X has no active support. We generally develop many projects on a single machine with different requirements(python packages). If we install python packages globally some ptojects may not work properly. To a

Read more

Python working with for loop

Python working with for loop
Let's start working with for loop in python. For loop is used when want to execute a block of code repeatedly a fixed number of times. Python also comes with the support of iterating the sequences using the for loop. we can use any number of for loops one inside another. we call it as nested for loops. We can skip the execution of code that is insi

Read more

Python working with if ... elif ... else conditions

Python working with if ... elif ... else conditions
Lets start working with if ... elif .. else conditions in python. "if ... elif .. else" allow us to take decisions. It can be nested. In some cases we may need to execute the code based on conditions. Then we use "if ... elif ... else" conditions in python. For example, if we wan to sort the students based on their grades then we have to use these

Read more

understanding the request-response lifecycle in Django

understanding the request-response lifecycle in Django
Let's start understanding the request-response lifecycle of a Django application. Every web application uses HTTP/HTTPS protocol. In the HTTP/HTTPS protocol client sends a request to the server based on the request data server sends the response back to the client. It's the basic principle of HTTP protocol. While setting up the django application i

Read more

django custom path converters

django custom path converters
In django version 2.0 introduced new way to write url patterns using "path". In django 2.0 regular expression type "url" is removed and added 2 things to work with urls. 1. using "path" and 2. using "re_path". For writing the clean urls django provided the path converters. It helps us to write clean and neat code and improves code readability. defa

Read more

working with xls and xlsx files in python

working with xls and xlsx files in python
Let's start working with xls and xlsx files in python. We can read data from xls or xlsx files using python programming and we can also write to xls or xlsx files using python programming. We do this by using the python package "openpyxl". The package "openpyxl" can be found in Python Package Index. So, we can easily install it with python pip. I r

Read more

django image and file upload using ajax

django image and file upload using ajax
Let's learn about how to work with Django image and file upload using Ajax. In most of the cases I personally use django file or image uploads using ajax. If we use normal upload then browser will reload the page in order to load the requested response and we will not have the files in the file fields due to page refreshed by the browser, again use

Read more

working with vim editor in ubuntu

working with vim editor in ubuntu
Let's start working with vim editor on ubuntu. vim is a light weight and powerful text editor used with the command line. It is very useful for system administrators. when deploying the application on the server normal GUI based text editors will not work. Because, GUI is absent on the deployment servers. We also have nano editor but it' doesn't ha

Read more

Python working with lists

Python working with lists
List is a one of the most used data types in python programming. It is a heterogeneous and ordered set of data structure in python. As it is an ordered data structure so, it obiviously supports indexing. We can access the elements of a list using index. It supports both positive and negative indexing. Positive index starts from 0 and negative index

Read more

Python working with frozenset data type

Python working with frozenset data type
Frozenset is an immutable unordered collection of unique elements. It holds collection of element but it does not guarantee the order of the elements in it. As it is immutable we cannot able to update the data once created. when we need to get a unique elements out of group of the repeated elements then we can simply use built-in function "frozense

Read more

Python working with tuple data type

Python working with tuple data type
Tuple is a sequential data structure in python. It is a immutable data type so, we cannot make any modifications to the tuple once created. Tuple stores the data in a sequencial manner. we can access the data in the tuple with indexs. Form the from index starts from 0, 1,2, 3, etc. Tuple also supports negative indexing. Form the rear the index star

Read more

Python working with strings

Python working with strings
String is a most used data type in python programming. A string is simply a series of characters. Anything inside quotes is considered as a string in Python, we can use either single or double quote. As python is a case sensitive language so string 'an' is considered different from string 'An'. In python string represented by data type "str". Note:

Read more

python polymorphism

python polymorphism
Polymorphism can be defined as declaring a uniform interface that is not aware of the type of the data, leaving implementation details to concrete data types that implement the interface. In general terms we can define it as different objects acts differently for same interface. In python we can implement polymorphism in two ways. polymorphism with

Read more

Python working with while loop

Python working with while loop
Let's start working with while loop in python. While loop is used to execute a block of code until certain condition is met. we can also terminate it before using the python keyword "break" If condition is not met then it will run for infinite number of times and we should avoid it. Unlike for loop it won't run for a fixed number of times. Syntax o

Read more

Python working with functions

Python working with functions
A function in python defined as a a group of statements that required to perform a task which takes required inputs and returns the output. We have two types of functions 1. built-in functions and 2. user defined functions. We have many built-in functions in python. You can see the list of pyhon built-in functions in in python documentation. Syntax

Read more

Python working with dict data type

Python working with dict data type
Lets start working with dict data type in python. Dictionary is collection of unordered set of key, value pairs. We can create an empty dictionary with the empty braces {}. dict data type in python is one of the most used datatypes in python builtin data types. We can only able to use keys which are in immutable nature. i.e. we can use string, tupl

Read more

Python working with classes and objects

In this article we will learn how to work with classes and objects in python. Python classes are mainly used for code reusability and better maintainability. You might have a question that we have a functions why do we need classes ? that's a good question. By using functions we can reuse the functionality In some cases we may need to hold the data

Read more

Python working with set data type

Python working with set data type
Lets start working with set data type in python. Set is a heterogeneous un-ordered set of elements with no repetition. set data structure is also just like frozensets. The only difference between sets and frozensets is sets are immutable where as frozensets are not mmutable in nature. we can use sets to checking of membership and eleminating the re

Read more

introduction to javascript programming

introduction to javascript programming
Javascript is a dynamic client side, interpreted and prototype based programming language. It's also used as a server side programming language in frameworks like nodejs, Apache CouchDB.JS .JavaScript follows the standards of ECMA(European Computer Manufacturers Association). All modern Web browsers support JavaScript with built-in interpreters. Di

Read more

django html to pdf using pdfkit and wkhtmltopdf

django html to pdf using pdfkit and wkhtmltopdf
In many ecommerce django/python projects we sent invoices to the users in an email. We generally attach pdf documents to the email while sending the invoices to the user. Most of these invoices are pdf documents. Django is the most used python web framework of python programming language. In django, to generate invoice we generally uses html templa

Read more

understanding of HTTP protocol

understanding of HTTP protocol
Before talking about HTTP Protocol, let's talk about "Protocol". A protocol is a set rules to be followed to communicate with one another. Let's take two persons say A, B. Person A lives in USA and person B lives in India and he doesn't know english. Person A sent a message to B. Inorder to understand the message, B has to follow english language g

Read more

understanding Model View Controller(MVC) in Django

understanding Model View Controller(MVC) in Django
What is Model View Controller? We call it in short MVC. It's a software architecture pattern that is used to devide the complex software into simple parts based on the functionality. When we use Google for web search, we simply open Google and search for "food" let's say. Then google will show us results about food. This what we see. But, actually

Read more

understanding django project structure

understanding django project structure
In the previous article we have seen how to setup the django development environment. In this article we will learn about how to create django proect and django project structure. We care about project structure because it helps us to organise the complex project code. A well structured project will helps the developers to navigate through the code

Read more

usage of property decorator in python

usage of property decorator in python
In this article we will learn about usage of property decorator in python. "property" is a built-in decorator in python. "property" is mostly used with classes. The decorator "property" makes the method that acts like an attribute to the python class. "property" is a callable object in python. It has three methods "getter", "setter" and "deleter".

Read more

deploy django app with apache server on ubuntu

deploy django app with apache server on ubuntu
In this article we will learn about how to deploy django app on apache server. Apache server is a free and open-source HTTP server that is free to use. It is a cross platform web-server, It support's most of the operating systems like windows, linux, Mac, etc. Apache server is not intended to use to create any website. The main purpose of apache is

Read more

Python working with numbers

Python working with numbers
Python has four basic number types. 1. Integers(int), 2. Floating point numbers(float), 3. Long integers(long), 4. Complex Numbers(complex). All these numeric types are immutable data types, it means changing the value of a numeric data type will results in a newly creation of an object. Integers(int) An integer is a whole number (not a fractional

Read more

Python working with operators

Python working with operators
In this article we will learn about different types of operators & working with operators in python. An operator is a symbol or a character in programming which takes two operands to perform an action. For example, in the expression "4 + 5" , "+" is an operator It will perform sum of numbers "4" and "5" and returns result "9". Types of operators in

Read more

Python working with boolean data type

Python working with boolean data type
Boolean data type is a one of the data types in python programming language. Boolean data has only two values True and False. It is mostly used to check whether the given statement is correct or not. It is the most used data type in any programming languages. Boolean data intended to use for Boolean Algebra . In python we mostly use it conditional

Read more

Python Variables and data types

Python Variables and data types
Let's begin learning variables and data types in python programming. In this article we will learn about how to use variable to store the data. we will also learn about different data types provided by python programming language. In python, without using the variables and data types we can't able write programs that can solve problems. What is a v

Read more

Python Introduction to programming

Python Introduction to programming
Python is a high-level and interpreted programming language. It is created by Guido van Rossum. Python first released in 1991, Python has a good design philosophy. It provides features like code readability, and a syntax that allows fewer lines of code to implement functionality compare to other programming languages. Python is a general purpose pr

Read more

Brief introduction to computers and programming

Brief introduction to computers and programming
Lets talk a little bit about computer. If we do not have computers most of the works will take much time to complete it. Computers reduces the human efforts and speedup the working process. It doesn't make errors while doing a task, but humans do. There are other factors that affect humans to make errors. Lets start with introduction to computers a

Read more

setting up django development environment

setting up django development environment
Django Web Framework is becoming very popular because of its easyness to use and support for rapid development with good security and reliability. Django developers has a good demand in the industry. Before we are diving into django we need to install "python 3.x.x" in our OS(operating systems). Django is no longer providing the support for python

Read more

Support Me on Patreon