authentication in Django Rest Framework

authentication in Django Rest Framework
In previous articles we have developed an open API i.e any user (Authenticated and Un-authenticated) can access the API resource. If we want to want to know the information who is accessing the API then we have to autheticate the user. Authentication means the process or action of verifying the identity of a user. REST framework provides a number o

Read more

python exception handling

python exception handling
python exception handling is one of the concepts in python programming. Before start working with exceptional handling in python what is an exception ? An exception is an event which occurs while running the program which stops the program to work further. Exception also tells about the problem in the code execution. We can write our own exception.

Read more

python reading and writing files

python reading and writing files
File reading and File writing is widely used concept in python because, As we (i.e humans) are lazy we do not remember all the information so we invented the computers(i.e storage devices) to store the information. where will computers store the information? Computer always stores the information in files. Hence, As we programmers we have to learn

Read more

python writing modules and packages

python writing modules and packages
We basically write computer programs to solve the problems. Problem may be simpler or moderate one or a complex. For simple problems we can solve it with 50 to 80 lines of code. If it is the case then we can easily manage the code. But, if code grows in an amount thousands of lines then obiviously it will be very difficult to maintain that code. So

Read more

python staticmethod, classmethod and instancemethod

python staticmethod, classmethod and instancemethod
We have three types of class based methods in python. They are 1.static method, 2.class method and 3.instance method. When we are working with classes we will have to deal with different types of scenarios. Based on the scenario we have to use the one of the method types. Let's get started with these python methods. Python Static Methods In python

Read more

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

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

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

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

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

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 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 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 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 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 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

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

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

Introduction to django web framework

Introduction to django web framework
Django is a high level python web framework. It is a open source web framework released under the licence of BSD. Django allows developers to build web applications in a short span of time. Django applications are powerful, fast, most secure and exceedingly scalable. Django was designed to help developers to complete the web applications as quickly

Read more

using custom user model in django

using custom user model in django
When we start a new project we have to use custom user model in django application. Because, django provides basic fields required for the user. We may require to add extra fields in the future. So, we have to use custom user model. To implement the custom user model in django application we do not need to rewrite the model from the scratch. We ca

Read more

why tuple is faster than list in python ?

why tuple is faster than list in python ?
In python we have two types of objects. 1. Mutable, 2. Immutable. In python lists comes under mutable objects and tuples comes under immutable objects. Tuples are stored in a single block of memory. Tuples are immutalbe so, It doesn't require extraspace to store new objects. Lists are allocated in two blocks: the fixed one with all the Python objec

Read more

How to install python virtualenv?

How to install python virtualenv?
virtualenv is a python package. It is used to create an isolated python environments. virtualenv allows us to work with different versions of packages for different projects. when we work with projects, the requirements will change from project to project. If we use python package lets say celery==1.0 in some projects we may need to use celery==2.0

Read more

How to Install pip in Ubuntu (Linux)

How to Install pip in Ubuntu (Linux)
pip stands for "preferred installer program". pip - python package manager is used to manage and install python packages software packages. It is a package management system.we can find all python packages irrespective of the python version python2 or python3 which were uploaded to Python Package Index(PyPI). pip is the python package manger used t

Read more

install pip on windows

install pip on windows
pip - python package manager. It manages the python packages. It's an opensource software. pip stands for "preferred installer program".pip is used to install and manage software packages written in Python. It is a package management system.we can find all python packages irrespective of the python version python2 or python3 which were uploaded to

Read more

how to install python on windows

To install python on windows go to "python software download for windows" and choose the python version and download it. Most of the python applications are upgraded to python3 so, I recommend you to download the python version 3. After downloading follow the below steps to install it Go to the directory where the python software is downloaded Sele

Read more

reading and writing csv files using python

reading and writing csv files using python
CSV is stands for comma seperated values. CSV file format is most commonly used format for imports and exports of data to spreadsheets and databases. Advantages to using csv edit csv file manually with any text editor ease of parsing and implementing the data in csv faster to handle the csv and smaller file size csv is considered to be standard fo

Read more

python memory management - memory allocation and garbage collection

python memory management - memory allocation and garbage collection
Memory allocation in python In python everything is considered as an object. In python we do not have variables instead python has names. When we declare a name/variable in python it stores the name in the memory. Every python name/variable points to its reference in the memory and reference points to the object. Let's consider the example code "a

Read more

signup or sign-in using facebook to django application

signup or sign-in using facebook to django application
Nowadays most of the users are having the facebook account. Registration/Login will take the time fill the form and submit to create or login to our website. Adding the functionality to login/signup with facebook makes it very easy to login or to register to our website. There are many third party django packages are available to add facebook signu

Read more

signup or sign-in using google to django application

Nowadays most of the users are having the facebook account. Registration/Login will take the time fill the form and submit to create or login to our website. Adding the functionality to login/signup with google makes it very easy to login or to register to our website. There are many third party django packages are available to add google signup or

Read more

generators and its usage in python

generators and its usage in python
Lets start with generators and its usage in python. A generator is a function in python which returns a python object. The returned object is an iterable object it like an array. Every object in the array is just a lazy function with parameters are ready for call. Generators are memory efficient because of its lazy evaluation. When we call method "

Read more

understanding of python slice notation

understanding of python slice notation
Lets start with understanding of python slice notation. We can access element in python lists/iterables by indexing. Slicing in python lists is defined as taking a part of the list from a bigger list. In python slicing takes 3 arguments 1. start index, 2. end index, 3. step to skip number of indexes. when we take slice in list it will create a new

Read more

Basic understanding of class in python

Basic understanding of class in python
Before starting with understanding classes in python lets talk about the basic terminology of object oriented programming. Class: A class is a basic design or a plan to an object. Class explains about the properties and behaviour of an object. In other words a class can be defined as it is a blueprint that defines the variables and methods common t

Read more

how to use *args and **kwargs in python

how to use *args and **kwargs in python
Python programming language is a simple and powerful language. It provides simple syntax with powerfull features. In this article we will discuss how to use *args and **kwargs in python. *args and **kwargs are magic powers of python. we use *args for unpacking of arguments and **kwargs for unpacking of keyword arguments. {% include "adsense/respon

Read more

iterators in python

iterators in python
Iterators in python is one of the simple and strong features of python. We already know that in python everything's an object. So, iterator is also a python object, which has a special method called "next". In python iterator acts like a container. When we call method "next" on the iterator object. It will creates and return the objects onfly. Aft

Read more

Support Me on Patreon