Programming Articles

Page 360 of 2547

Adding a DeleteView in Django

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 3K+ Views

A DeleteView is a Django generic view that provides an easy way to delete model instances from your application. It handles the deletion logic and provides confirmation functionality, similar to Django's admin interface. Setting Up the Project First, create a Django project and app. Add your app to settings.py − INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'modelFormsDemo', # Your app name ] ...

Read More

How to make a Country field in Django?

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 3K+ Views

If you need to add a location field in your form or database, you can use a CharField but it's not the ideal solution. Django provides a third-party package called 'django-countries' that offers a dedicated country field with built-in validation and country list management. In this article, let's see how to use django-countries to add a Country field in Django. Installation and Setup First, create a Django project and an app. Add the app in INSTALLED_APPS and set up URLs. Install the django-countries module ? pip install django-countries In settings.py, add this ? ...

Read More

How to add a captcha in a Django website?

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 3K+ Views

CAPTCHA is a security feature used to verify that users are human, not bots. Django provides an easy way to implement CAPTCHA using the django-simple-captcha library, which generates image-based challenges for user verification. In this article, we'll learn how to add CAPTCHA functionality to a Django website step by step. Installation First, install the required library − pip install django-simple-captcha Django Configuration Settings Configuration Add the CAPTCHA app to your settings.py − INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', ...

Read More

Making a URL shortner app in Django

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 448 Views

In this article, we will see how to make a URL shortener app in Django. It is a simple app which will convert a long URL into a short one using the pyshorteners library. First, create a Django project and an app. Do some basic settings like including URLs of app and adding the app to INSTALLED_APPS in settings.py. Installing Required Package Install the pyshorteners module − pip install pyshorteners Setting Up URLs In app's urls.py − from django.urls import path from .views import url_shortener urlpatterns = [ ...

Read More

Making a simple counter app using request.session in Django

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 776 Views

In this article, we are going to see how to make a super simple counter app using Django sessions. By clicking a button, the counter increments and persists even after closing the browser tab. This demonstrates how to use request.session for state management in Django. Setting Up URLs In urls.py, add the following lines − from django.urls import path from . import views urlpatterns = [ path('', views.counterView, name='counter'), ] Here we set up the counter view on the home URL. Creating the View In views.py, add ...

Read More

Making a Pickle field in Django models

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 2K+ Views

Pickle in Python is primarily used in serializing and deserializing a Python object structure. In other words, it's the process of converting a Python object into a byte stream to store it in a file/database, maintain program state across sessions, or transport data over the network. In this article, we are going to see how to make a Django field which will save pickle objects. We will work with models.py and Django shell to demonstrate the functionality. Installation First, install the django-picklefield package − pip install django-picklefield Creating the Model In models.py ...

Read More

Django – Making a contact form and storing its data without model, query and html

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 1K+ Views

In Django, creating a contact form typically requires managing forms, views, models, and admin registration. However, you can simplify this process using the django-contactforms package, which provides a predefined contact form and model without writing custom code in models.py, views.py, or HTML templates. Installation and Setup First, create a Django project and app, then install the required package: pip install django-contactforms Add the package to your settings.py: INSTALLED_APPS += ["contactforms"] URL Configuration In your project's urls.py, configure the URL patterns: from django.contrib import admin from django.urls import ...

Read More

Importing data into models in Django

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 4K+ Views

In this article, we will learn how to import data from JSON format into Django models. Django supports importing data from various formats including JSON, CSV, XLSX, and YAML using the django-import-export package. We'll create a Django project with a simple model and configure it to accept imported data through the admin interface. Setup Requirements First, install the required package ? pip install django-import-export Add the package to your Django project's INSTALLED_APPS in settings.py ? INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', ...

Read More

Implementing models reversion in Django

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 980 Views

In this article, we will learn how to implement django-reversion for tracking model changes, recovering deleted data, and maintaining version history of Django model objects. Django reversion provides powerful data recovery capabilities and complete object tracking. Setup and Installation First, create a Django project and app, then install the required package − pip install django-reversion Add reversion to your INSTALLED_APPS in settings.py − INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', ...

Read More

How to make any Django model's file downloadable?

Ath Tripathi
Ath Tripathi
Updated on 26-Mar-2026 1K+ Views

You can use the django-downloadview package to make any file in your Django model downloadable. This package provides a simple way to serve files while handling security and performance considerations. In this article, we will see how to make a file downloadable in our Django project using django-downloadview. Installation First, install the package using pip: pip install django-downloadview Now create a Django project and an app. Set up urls and add the app in INSTALLED_APPS. Also set up MEDIA_ROOT and MEDIA_URL in settings.py. Creating the Model In models.py, create a model ...

Read More
Showing 3591–3600 of 25,466 articles
« Prev 1 358 359 360 361 362 2547 Next »
Advertisements