Found 52 Articles for Django

How to protect against cross-site scripting (XSS) in Django?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:28:21

552 Views

Web applications that fail to appropriately escape user-submitted text before rendering it into HTML are vulnerable to cross-site scripting (XSS). An attacker can use this to inject arbitrary HTML into your Web page, commonly in the form of a element. XSS attacks are frequently used by attackers to steal cookie and session information, as well as to fool users into providing personal information to the wrong person. Phishing is another term for this. We will look at a common case because this type of attack can take many different shapes and has nearly unlimited variations. Let us consider simple ... Read More

What is CSRF token in Django?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:31:35

13K+ Views

CSRF stands for Cross Site Request Forgery, and it is said to occurs when a malicious Web site deceives users into unwillingly and unknowingly loading a URL from a site where they've previously been authenticated, thus exploiting their status and also putting the data at risk. To understand what the CSRF attack exactly is, let us look into an example. Assume you're logged into csrfexample.com's webmail account. The Log Out button on this webmail site leads to the URL csrfexample.com/logout. That is, all you have to do to log out is visit the page csrfexample.com/logout. A rogue site can force ... Read More

How to make Django admin more secure?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:20:02

469 Views

Django is a web framework that is popular for its ease of usage. Django like many other web frameworks comes equipped with a lot of features and functionalities that can be used without much code to write. Django-admin is one of those features. The automatic admin interface is one of Django's most powerful features. It reads metadata from your models to create a model-centric interface for trusted users to manage content on your site. The admin's recommended use is limited to the internal management tool of an organization. It is not meant to be the foundation for your complete front ... Read More

How to add security to your Django website?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:07:27

585 Views

Communication through the web happens through a HTTP connection and more often than not you never know who is on the other end. It may be one of your users, but it could also be a malicious hacker searching for an opportunity. Any data from the browser, regardless of its source, should be processed with caution and checked for threats. This includes data from Web forms as well as information from HTTP headers, cookies, and other request metadata. As Web developers, we have a duty to do what we can to combat these forces of darkness. Every Web developer needs ... Read More

How to add validation to your Django project?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:04:13

501 Views

Validation is the process through which the computer automatically checks to ensure that the data entered is sensible and reasonable. It does not provide if the data entered is accurate or not. Many of us are familiar with email or phone validation that is usually a part of most websites. When we enter the email address in the wrong format or if the phone number entered does not contain 10 digits, a warning is usually displayed to enter the output in the accepted format. This is validation. Most developers add validation to their projects to ensure that the data they ... Read More

How to upgrade django to a newer version in anaconda?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:02:38

583 Views

Anaconda is very popular framework used for python development. It enables users to develop web applications, desktop application, data analysis programs, machine learning applications and more. Another great feature of anaconda is that it enables users to create virtual environments, so installing a package or library only in that environment saves a lot of space and time. Django is widely used for python web development due to its ability to ease server-side scripting. To install Django in your anaconda environment, you can use the following command. conda install django To create a virtual environment and install Django inside it, ... Read More

What are projects and apps in Django?

Gayatri Jandhyala
Updated on 02-Sep-2022 14:01:22

615 Views

Django is a popular web framework used for the development of websites. Django follows the MVT (Model-View-Template) architecture. Here, Model is responsible for the data and logical structure of your project, View contains the business logic and Template is responsible for rendering the HTML files. The hierarchy of project in Django consists of projects and apps. Project refers to the entire web application. Apps are the functionalities that are part of the web application. All of them work individually and can be reused. Creation of a project A project is essentially a collection of settings for a specific instance of ... Read More

How to install Django in Anaconda?

Gayatri Jandhyala
Updated on 02-Sep-2022 13:59:28

11K+ Views

In this section, we are going to look at how to install anaconda in your computer. And then we will move into how to install Django in this anaconda environment. Anaconda is a popular run time environment for python programs. The anaconda distribution provides many environments such as Spyder which is an IDLE to run python programs, Jupyter, which is a web application that lets users to perform visualizations and more, and anaconda also includes a PowerShell Prompt that is a command prompt of sorts that lets users to run programs on the command line. Anaconda Installation The steps to ... Read More

Form validation using Django

Hafeezul Kareem
Updated on 13-Nov-2020 12:58:00

4K+ Views

In this article, we are going to learn how to validate a form in django. Django comes with build-in validators for forms. We can use them in the tutorial to validate forms.You must familiar with the Django to follow along with this tutorial. If you are not familiar with Django, then this article is not for you.Set up the basic Django project with the following commands.mkdir form_validation cd form_validation python -m venv env (Activate environment based on your OS) pip install django===3.0 django-admin startproject form_validation . (Don't forget dot(.) at the end) python manage.py startapp ... Read More

Add the slug field inside Django Model

Hafeezul Kareem
Updated on 21-Sep-2020 13:02:30

457 Views

In this tutorial, we are going to learn about the SlugField in Django.SlugFieldSlugField is a way to generate a URL using the data which we already have. You can generate URL using your title of the post or page. Let's see one detailed example.Let's say we have an article with name This is from Tutorialspoint with id = 5. Then we can have URL as www.tutorialspoint.com/posts/5/. It's difficult for the content writers to recognize the article with the previous URL. But, if you have a URL like www.tutorialspoint.com/this-isfrom-tutorialspoint, then it's easy for us to identify the piece. So, SlugField is ... Read More