Skip to main content

“Password Reset in Django – Complete Guide”

 Password Reset in Django – Complete Guide



🔐 Introduction

Web applications lo Password Reset feature chala important.
User password marchipothe, easy ga recover chesukovadaniki use avutundi.

Real-time lo:

  • Gmail
  • Facebook
  • Instagram

anni password reset system use chestayi.


⚙️ How Password Reset Works?

👉 Step-by-step flow:

  1. User “Forgot Password” click chestadu
  2. Email enter chestadu
  3. System reset link send chestundi
  4. User link open chestadu
  5. New password set chestadu

👉 Idi secure ga untundi because:

  • Token based verification
  • Time limit untundi

⚙️ Django Password Reset Code

1️⃣ settings.py (EMAIL Setup)

# settings.py

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

👉 Dev lo console lo email link chupistundi
👉 Production lo Gmail SMTP use cheyachu


2️⃣ urls.py

from django.urls import path
from django.contrib.auth import views as auth_views

urlpatterns = [

path('password-reset/',
auth_views.PasswordResetView.as_view(
template_name='registration/password_reset.html'
),
name='password_reset'),

path('password-reset/done/',
auth_views.PasswordResetDoneView.as_view(
template_name='registration/password_reset_done.html'
),
name='password_reset_done'),

path('reset/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(
template_name='registration/password_reset_confirm.html'
),
name='password_reset_confirm'),

path('reset/done/',
auth_views.PasswordResetCompleteView.as_view(
template_name='registration/password_reset_complete.html'
),
name='password_reset_complete'),
]

🎨 Templates

📄 password_reset.html

<h2>Forgot Password</h2>

<form method="POST">
{% csrf_token %}
{{ form.as_p }}

<button type="submit">Send Reset Link</button>
</form>

📄 password_reset_done.html

<h2>Email Sent</h2>
<p>Check your email for reset link 📩</p>

📄 password_reset_confirm.html

<h2>Set New Password</h2>

<form method="POST">
{% csrf_token %}
{{ form.as_p }}

<button type="submit">Change Password</button>
</form>

📄 password_reset_complete.html

<h2>Password Changed Successfully 🎉</h2>
<a href="{% url 'login' %}">Login</a>

🔗 Add Link in Login Page

<a href="{% url 'password_reset' %}">Forgot Password?</a>

🧠 Explanation (Simple)

👉 Django automatically:

  • Token generate chestundi
  • Email send chestundi
  • Password update handle chestundi

👉 Manam:

  • URLs configure chestam
  • Templates create chestam

🔥 Final Flow

👉 User clicks Forgot Password
👉 Email link vastundi
👉 Link open chesi password change chestadu


Comments

  1. it is good and best content i never ever seen

    ReplyDelete

Post a Comment

Popular posts from this blog

Django ante enti? (Beginner Friendly Telugu Guide)

  Introduction Meeru web development start cheyyali anukuntunnara? Leka backend development nerchukovali anukuntunnara? Appudu meeru tappakunda vinnadi oka peru 👉 Django Ee article lo manam simple ga, clear ga ardham ayyela chuddam — Django ante enti, enduku use chestaru, ela start cheyyali.

Python Day 5 – If Else Conditions

  🐍 Python Day 5 – If Else Conditions 🧠 Introduction 🐍 Python Day 5 – If Else Conditions Ippati varaku manam operators nerchukunnam. I roju manam decision making (If-Else) nerchukundam. 👉 Program lo condition base chesi decisions tiskovadaniki use avutundi 💡 Example: Age 18 kanna ekkuva unte → eligible Lekapothe → not eligible 🔹 Basic If Condition age = 20 if age > 18 : print ( "Eligible" ) 🔹 If-Else Condition age = 16 if age >= 18 : print ( "Eligible" ) else : print ( "Not Eligible" ) 🔹 If-Elif-Else marks = 75 if marks >= 90 : print ( "Grade A" ) elif marks >= 60 : print ( "Grade B" ) else : print ( "Grade C" ) 🧪 Real Example (User Input) age = int ( input ( "Enter your age: " )) if age >= 18 : print ( "You can vote ✅" ) else : print ( "You cannot vote ❌" ) ⚠️ Important Points 👉 Indentation (space) very import...

Django Templates & HTML Rendering (Complete Guide Telugu)

  Introduction Previous article lo manam Views & URLs chusam. Ipudu next important concept 👉 Templates & HTML Rendering Django lo dynamic HTML pages ela create cheyyalo ee article lo nerchukundam 🔥 🧠 Templates ante enti? 👉 Template ante HTML file "T emplate ante HTML file matrame kaadu, Django lo dynamic content ni display cheyadaniki use chestam. Example ga, database lo unna blog posts ni HTML page lo chupinchadaniki templates use avutayi. " But special enti ante: 👉 Dynamic data display cheyyachu (Python data → HTML lo show) 📁 Templates folder create cheyyadam Mee app lo templates ane folder create cheyandi: myapp/ templates/ index.html ⚙️ settings.py lo config cheyyali settings.py open cheyandi: TEMPLATES = [ { 'DIRS': [], ... }, ] 👉 Usually app templates automatic ga detect chestundi 💻 Simple HTML Template index.html : <!DOCTYPE html> <html> <head> <title>Django Page</title> ...