Programming Articles

Page 26 of 2547

Django query count in terminal for debugging

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

In this article, we'll use the django-querycount library to monitor database queries in Django applications. This debugging tool displays a detailed report of database query counts in the terminal, helping developers identify performance bottlenecks by tracking every database hit on model objects. Installation First, install the django-querycount package using pip ? pip install django-querycount Configuration Add the QueryCountMiddleware to your Django project's middleware in settings.py ? MIDDLEWARE += [ 'querycount.middleware.QueryCountMiddleware', ] This middleware will automatically monitor all database queries when DEBUG = True in your ...

Read More

Django model object hit counting

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

In this article, we will create a Django project that tracks and stores hit count data for model objects. This functionality helps generate useful analytics reports by monitoring page views and user interactions. Installation and Setup First, install the django-hitcount module using pip ? pip install django-hitcount In your settings.py file, add the hitcount app to your installed apps ? INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', ...

Read More

Django – Admin based File Management

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

Django's admin panel can be enhanced with django-filer to provide comprehensive file management capabilities. This allows administrators to upload, organize, and manage various file types directly from the admin interface. Installing Django-Filer First, install the required package using pip ? pip install django-filer Configuration Add the necessary apps and configuration to your settings.py file ? INSTALLED_APPS = [ ... 'easy_thumbnails', 'filer', 'mptt', ... ] THUMBNAIL_HIGH_RESOLUTION = True THUMBNAIL_PROCESSORS = ...

Read More

Creating a screenshot taking website in Django

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

In this article, we will create a Django website that captures screenshots of your screen. When you click "Take Screenshot", it saves the image to the media folder and displays it on the webpage. Setting up the Django Project First, create a Django project and app. In settings.py, add your app name to INSTALLED_APPS and configure media settings − MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' This sets up the media folder for image storage. URL Configuration In your project's urls.py − from django.contrib import admin from django.urls import ...

Read More

Client side image zooming and rotating in Django

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

Client-side image manipulation allows users to zoom and rotate images before uploading in Django applications. The django-client-side-image-cropping library provides jQuery-powered zooming and rotating functionality that works directly in the browser. Installation and Setup Create a Django project and app, then configure basic settings. Install the required library ? pip install django-client-side-image-cropping Add the library to your INSTALLED_APPS in settings.py ? INSTALLED_APPS += ['client_side_image_cropping'] Model Configuration Create a simple model with an image field in models.py ? from django.db import models class Data(models.Model): ...

Read More

Adding translation to a model instance in Django

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

In this article, we are going to learn how to create a translation for any model instance in Django. Sometimes, you may need to save data like names, descriptions, or text content that must be rendered in different languages. Instead of complex database management, we'll use django-klingon to achieve this with minimal setup. We'll focus on settings.py, models.py, and admin.py to implement multilingual support for Django model fields. Installation and Setup First, install the django-klingon package ? pip install django-klingon In settings.py, add the following configuration ? INSTALLED_APPS += ['klingon'] KLINGON_DEFAULT_LANGUAGE ...

Read More

How to add a Money field in Django?

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

Django's default IntegerField and DecimalField don't handle currency properly for financial applications. The django-money library provides a MoneyField that handles currency symbols, decimal precision, and multi-currency support. Installation and Setup First, install the django-money package − pip install django-money Add it to your Django project's settings.py − INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'djmoney', # Add this line ...

Read More

Adding JSON field in Django models

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

In this article, we will see how to add JSON fields to our Django models. JSON is a simple format to store data in key-value pairs using curly braces. JSON fields are particularly useful when you need to store flexible, unstructured data like user preferences, metadata, or configuration settings. First, create a Django project and an app. Make sure to add your app to INSTALLED_APPS, set up URLs, and configure your basic project structure. Modern Approach (Django 3.1+) Django 3.1 and later versions include native JSON field support, eliminating the need for third-party packages ? ...

Read More

How to add extra security to Django admin using fake admin login?

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

Adding extra security to Django admin can be achieved using a fake admin login page. This technique creates a "honeypot" that logs unauthorized access attempts while hiding the real admin interface on a secret URL. The django-admin-honeypot package creates a fake Django admin page that captures login attempts with IP addresses, regardless of whether correct or incorrect credentials are used. Installation First, install the required package ? pip install django-admin-honeypot Configuration Settings Configuration Add the honeypot app to your INSTALLED_APPS in settings.py ? INSTALLED_APPS = [ ...

Read More

How to add Django debug toolbar to your project?

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

The Django Debug Toolbar is a powerful debugging tool that displays detailed information about database queries, request/response data, templates, and performance metrics. It's essential for optimizing Django applications during development. Installation First, install the django-debug-toolbar package using pip − pip install django-debug-toolbar Configuration Steps Step 1: Add to INSTALLED_APPS Add 'debug_toolbar' to your INSTALLED_APPS in settings.py − INSTALLED_APPS = [ # ... 'debug_toolbar', 'myapp' ] Step 2: Configure Middleware Add the debug toolbar middleware to ...

Read More
Showing 251–260 of 25,469 articles
« Prev 1 24 25 26 27 28 2547 Next »
Advertisements