Found 33676 Articles for Programming

How do map, reduce and filter functions work in Python?

Vikram Chiluka
Updated on 15-Sep-2022 09:21:53

13K+ Views

In this article, we will show you the Python's map(), filter(), and reduce() functions add a touch of functional programming to the language. All three of these are convenience functions that can be replaced with List Comprehensions or loops but offer a more elegant and concise solution to some problems. map(), filter(), and reduce() all work in the same way. These functions accept a function and a sequence of elements and return the result of applying the received function to each element in the sequence. map() function Like reduce(), the map() function allows you to iterate over each item in ... Read More

Difference between indexing and slicing in Python

Vikram Chiluka
Updated on 15-Sep-2022 09:05:41

13K+ Views

In this article, we will explain to you the differences between indexing and slicing in python. Indexing and slicing are applicable only to sequence data types. The order in which elements are inserted is preserved in sequence type, allowing us to access its elements via indexing and slicing. To summarise, Python's sequence types are list, tuple, string, range, byte, and byte arrays. And indexing and slicing are applicable to all of these types. Indexing The term "indexing" refers to refers to an element of an iterable based on its position inside the iterable. The indexing begins from 0. The ... Read More

Difference between for loop and while loop in Python

Vikram Chiluka
Updated on 26-Aug-2023 03:25:00

52K+ Views

In this post, we will understand the difference between the 'for' and the 'while' loop. For Loop A for loop is a control flow statement that executes code for a predefined number of iterations. The keyword used in this control flow statement is "for". When the number of iterations is already known, the for loop is used. The for loop is divided into two parts − Header − This part specifies the iteration of the loop. In the header part, the loop variable is also declared, which tells the body which iteration is being executed. Body − The body part ... Read More

How to add groups in Django using authentication system?

Gayatri Jandhyala
Updated on 05-Sep-2022 11:06:24

3K+ Views

Django is equipped with built-in permissions system that assigns permissions to specific users or groups of users. Permissions used by the Django-admin site are as follows, Users with the "view" or "update" permission for that type of object have access to view objects. Only users with the "add" permission for that type of item have access to view the "add" form and add an object. Users having the "change" permission for that type of item have access to the change list, the "change" form, and the ability to change an object. Only users having the "delete" permission for that ... Read More

How to create user and superuser in Django Authentication System?

Gayatri Jandhyala
Updated on 05-Sep-2022 11:04:37

4K+ Views

The demand for dynamic websites increased as more features were required in websites. In this, in addition to delivering content, the server stores data and responds to user input. One of the key reasons for having a dynamic site is the ability to authenticate users and limit the material they may access. User objects are the core of the authentication system. Like mentioned above, users are the people interacting with your site. they are used to enable things like restricting access, registering user profiles, associating content with creators etc. Let us go ahead and understand how to create users and ... Read More

How to change password of users in Django?

Gayatri Jandhyala
Updated on 05-Sep-2022 11:03:28

6K+ Views

Static and dynamic websites are the two types of websites widely used on the web. Django is a web development framework for creating dynamic webpages. A static website is one that only displays information and has no interaction other than simple page requests that is recorded on the server. The purpose of a static website is for the server to provide HTML, CSS, and JavaScript to the client. More features needed to be included in websites which increased the demand for dynamic websites. In which the server keeps data and responds to user input in addition to presenting content. The ... Read More

How to prevent session hijacking in Django?

Gayatri Jandhyala
Updated on 05-Sep-2022 11:01:14

1K+ Views

Session hijacking or session forging is another security issue that most websites are prone to. In this article, we will know more about the attack and how to protect your website against it. This is a wide class of attacks on a user's session data, rather than a specific assault. It has many forms and they are discussed below. A man-in-the-middle attack occurs when an attacker intercepts session data as it travels over the network. ... Read More

How to add authorization to your Django website?

Gayatri Jandhyala
Updated on 05-Sep-2022 10:59:57

847 Views

In order to work with users’ data, first we keep track of data using sessions and later we enable user login by using those sessions. A system that allows developers to authorize an auth/auth system is a term used to describe the system that enables user authentication and authorization. The name (auth/auth) recognizes that dealing with users is often a two-step process. Check a username and password against a database of users to verify (authenticate) that a person is who he or she claims to be. Verify (authorize) that the user is authorized to do a specific operation, usually ... Read More

How to add authentication to Django Website?

Gayatri Jandhyala
Updated on 05-Sep-2022 10:57:40

756 Views

In a web application, there are two key elements to data management. The first is to save data acquired from multiple browser queries, and the second is to use this preserved data to authenticate users. Sessions allow us to keep track of data across numerous browser queries. The second half of the equation is logging in users using those sessions. We cannot trust people to be who they claim they are, so we have to verify their identities along the process. Django, of course, includes tools to perform these and other typical tasks. User accounts, groups, permissions, and cookie-based user ... Read More

How to humanize tags in Django?

Gayatri Jandhyala
Updated on 05-Sep-2022 10:54:52

2K+ Views

Humanize means to make something more humane or human readable. To humanize tags means to makes it easier for the humans to understand. For example, 1800000000 becomes 1.8 billion or 10000 becomes 10, 000. There are simple changes that can be implemented to convert tags to a more human readable format. Django offers template filters that add human touch to data which makes it more appealing to read. To enable the usage of these filters, django.contrib.humanize should be added to the INSTALLED_APPS in the settings.py file of your project. INSTALLED_APPS = [ 'reglogin', 'mlmodel', ... Read More

Advertisements