Understanding the Difference Between __new__ and __init__ in Python
In Python's object-oriented programming, __new__ is a rarely used method compared to __init__. While __init__ is commonly mistaken for a constructor, it's actually an initializer. The true instance creation happens in __new__.
class Publication(object):
def __init__(self, name):
super(Publication, self).__init__()
self.name ...
Posted on Tue, 02 Jun 2026 17:27:29 +0000 by OzRedBoy
Enhancing Django Application Concurrency with uWSGI and Nginx
The default Django development server operates on a single thread, handling requests sequentially. This means a second request must wait for the first to complete before processing begins, leading to blocking behavior unsuitable for production workloads.
To achieve high concurrency, a common approach involves deploying Django with uWSGI as the ...
Posted on Tue, 02 Jun 2026 16:37:47 +0000 by LostKID
Working with Django's Authentication System
Initializing a Superuser
Execute the following management command to create an administrative account:
python manage.py createsuperuser
During the prompt:
Username: Required.
Email: Optional.
Password: Will be stored as a hash. If forgotten, you can manually replace the hash in the database, though resetting via management commands is preferr ...
Posted on Tue, 02 Jun 2026 16:24:57 +0000 by Negligence
Django URL Routing Patterns and Reverse Resolution Techniques
URL Routing Patterns
Django provides flexible URL routing through regular expressions:
# Basic URL pattern
url(r'^articles/$', views.article_list),
# Homepage pattern
url(r'^$', views.homepage),
# Django 2.x+ syntax
path('admin/', admin.site.urls),
re_path(r'^articles/$', views.article_list)
Unnamed and Named Groups
Unnnamed groups capture p ...
Posted on Mon, 01 Jun 2026 16:50:06 +0000 by isurgeon
Building a Customizable Admin Interface in Django
Initializing the Admin Module
Start by creating a new Django app to encapsulate the custom admin logic.
python manage.py startapp core_admin
Add core_admin to your INSTALLED_APPS list in the settings file. Then, include the app's URLs in the project's main urls.py:
url(r'^admin_panel/', include("core_admin.urls"))
Dynamic Model Re ...
Posted on Sat, 30 May 2026 18:02:42 +0000 by grimmier
Setting Up a Django Project Structure
Creating the Project and Appplication
# Generate the Django project structure named 'tpdemo'
django-admin startproject tpdemo
cd tpdemo
# Create a new application within the project
python manage.py startapp myapp
# Establish template directories
mkdir templates
templates/myapp
Database Configuration in settings.py
Modify tpdemo/tpdemo/setti ...
Posted on Fri, 29 May 2026 21:39:51 +0000 by Drezard
Understanding and Implementing Django Signals
Introduction to the Signal Mechanism
Django includes a robust signal dispatcher that facilitates communication between different parts of the application. This mechanism operates on the Observer pattern (also known as Publish/Subscribe). It allows specific "sender" components to notify "receiver" components when a specific a ...
Posted on Sat, 23 May 2026 20:53:42 +0000 by pavanpuligandla
Integrating Django, Vue, Axios, CORS, and Global Settings in a Full-Stack Project
Backend Setup with Django
Internationalization & Timezone
# d_prj/settings.py
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_TZ = False
Frontend HTTP Client: Axios
Installation & Global Registration
# v-proj/src/main.js
import axios from 'axios'
Vue.prototype.$http = axios
Sample GET Request inapting to Vue Lifecycle
// v-p ...
Posted on Fri, 22 May 2026 22:54:09 +0000 by andycastle
Advanced Django URL Routing Techniques
Django URL configuration
URL configuration (URLconf) acts as a map for the website that Django supports, linking URLs to the functions that should be called for those URLs.
We use this method to inform Django which function to execute when a specific URL is encountered.
URLconf setup
Basic format:
from django.conf.urls import url
urlpatterns = ...
Posted on Wed, 20 May 2026 18:47:40 +0000 by Runnion
Common User Login Modules and Their Usage
Using the 'next' Parameter on the Login Page
Determine if a next parameter exists in the URL of the user's login page. If it does, redirect to the URL the user was trying to access before logging in.
A common practice is to modify the login logic in the LoginView handler by adding the following code:
# Check if the request URL contains a 'next' ...
Posted on Tue, 19 May 2026 08:02:56 +0000 by omprakash