Posts

Privacy Policy for Mera Kharch

1. Introduction Welcome to Mera Kharch: Expense Manager. We value your privacy. This policy explains how we handle your data when you use our mobile application. 2. Data Collection (No Collection) Our app is designed to work Offline. We do NOT collect, store, or transmit any of your personal information, financial records, or sensitive data to our servers or any third parties. All data you enter (Expenses, Income, Categories) stays exclusively on your local device. 3. Permissions The app may ask for the following permission only to provide core features:  * Storage/Media: To export your expense reports in CSV/Excel format to your phone's memory. 4. Third-Party Services We do not use any third-party analytics (like Firebase Analytics), advertisements (if applicable), or tracking tools that monitor your behavior. 5. Data Security Since your data is stored locally on your phone (Local Database), its security depends on your device's overall security. We do not have access to your ...

crud operation

 Let’s go step by step on how to implement CRUD (Create, Read, Update, Delete) in Python Django . Step 1: Create a Django Project & App django-admin startproject myproject cd myproject python manage.py startapp myapp Add myapp in INSTALLED_APPS inside settings.py . Step 2: Create a Model In myapp/models.py : from django . db import models class Book ( models . Model ): title = models . CharField ( max_length = 200 ) author = models . CharField ( max_length = 100 ) published_date = models . DateField () def __str__ ( self ): return self . title Now run: python manage.py makemigrations python manage.py migrate Step 3: Create Forms (optional but easier) In myapp/forms.py : from django import forms from . models import Book class BookForm ( forms . ModelForm ): published_date = forms . DateField ( widget = forms . DateInput ( attrs = { 'type' : 'date' }) ) class Meta : model = Book ...

Complete CRUD REST API

  REpresentational State Transfer + Application Programming Interface REST API allows different applications (like mobile apps, frontend, backend) to talk to each other over the internet using HTTP methods (like GET, POST, PUT, DELETE). What is REST API in Django? In Django, you can create REST APIs using the library called Django REST Framework (DRF). With REST API in Django, you can: Send data to the backend (POST) Get data from the backend (GET) Update existing data (PUT/PATCH) Delete data (DELETE) pip install djangorestframework INSTALLED_APPS = [   ...   ' rest_framework ', ] | Method | Endpoint | Purpose | Example | | ------ | ------------------------- | -------------------- | ----------- | | GET | `/ api /students/` | Get all students | List view | | GET | `/ api /students/1/` | Get 1 student (id=1) | Detail view | | POST | `/ api /students/create/` | Create new student | Add | | PUT ...

Django Middleware – Complete

 What is Middleware? Middleware is a special layer in Django that processes every request and response globally before or after the view is called. It acts like a filter, gatekeeper or security guard in a web app. 🧠 Why is Middleware Important? Task Done using Middleware Block specific users ✅ Auto login redirect ✅ Theme (dark/light) toggle ✅ Add info to response/request ✅ Language / Location detection ✅ ⚙️ How Middleware Works in Django Browser → Middleware → View → Middleware → Response → Browser pip install django-ipware ✅ Step 1: Create Middleware File 📁 Create middleware.py in your Django app (e.g., main/middleware.py ) from ipware import get_client_ip from django . http import HttpResponse class BlockForeignMiddleware :     def __init__ ( self , get_response ):         self . get_response = get_response     def __call__ ( self , request ):         ip , _ = get_client_ip...

Cookie and Session

 Cookie Cookie is a small piece of data that a website saves in your browser to remember you or your preferences (like name, login status, language, etc.). 🧑‍💻 1. views.py from django.http import HttpResponse # Set Cookie def set_cookie(request):     response = HttpResponse("Cookie has been set")     response.set_cookie('user_name', 'Raj', max_age=3600)  # expires in 1 hour     return response # Get Cookie def get_cookie(request):     name = request.COOKIES.get('user_name')  # read cookie     return HttpResponse(f"Hello {name}") 🛣️ 2. urls.py from django.urls import path from . import views urlpatterns = [     path('set-cookie/', views.set_cookie),     path('get-cookie/', views.get_cookie), ] ✅ Session Definition Session is a way to store data on the server to remember the user between different pages (like login info, user ID, cart items, etc.) from django.http import HttpResponse # Set Session d...

Login + Register with Extra Info (Profile)

  authdemo/ │ ├── authdemo/           ← Project folder │   └── urls.py │ ├── users/              ← Custom user app │   ├── views.py │   ├── forms.py │   ├── urls.py │   └── templates/ │       └── users/ │           ├── login.html │           └── home.html │ └── manage.py Step 1: Project Setup django-admin startproject authdemo cd authdemo python manage.py startapp users ✅ Step 2: Add App to settings.py # authdemo/settings.py INSTALLED_APPS = [ ..., 'users', 'django.contrib.auth', 'django.contrib.sessions', ] ✅ Step 3: Create Profile Model # users/models.py from django . db import models from django . contrib . auth . models import User class Profile ( models . Model ):     user = models . OneToOneField ( User , on_delete = models . CASCADE )   ...

Django User Registration and Login System: Step-by-Step Guide

  Step 1: Create a Django Project django-admin startproject auth_demo cd auth_demo python manage.py startapp accounts 🧩 Step 2: Add App to settings.py INSTALLED_APPS = [     ...     'accounts',     'django.contrib.sessions',     'django.contrib.auth',     ... ] Also, add login URL if you want: LOGIN_URL = '/login/' 🧱 Step 3: Create URL Routes Create a file accounts/urls.py # accounts/urls.py from django . urls import path from . import views urlpatterns = [     path ( 'register/' , views .register_view, name = 'register' ),     path ( 'login/' , views .login_view, name = 'login' ),     path ( 'logout/' , views .logout_view, name = 'logout' ),     path ( 'dashboard/' , views .dashboard_view, name = 'dashboard' ), ] Now include this in the main urls.py : # auth_demo/urls.py from django . contrib import admin from django . urls import path , include urlpatterns = [    ...