11## Basic
22
3+
4+
35## Creation
46```
57django-admin startproject mysite
68cd mysite
7- python manage.py startapp blogs
9+ python manage.py startapp blog
810```
911
1012## setup
@@ -13,13 +15,26 @@ INSTALLED_APPS = [
1315 ...
1416 ' pages' ,
1517]
18+ ```
1619
20+ ### blog.urls.py
21+ ``` python
22+ from django.urls import path
23+ from . import views
1724
25+ urlpatterns = [
26+ path(' ' , views.home, name = ' home' ),
27+ path(' about/' , views.about, name = ' about' ),
28+ path(' contact/' , views.contact, name = ' contact' ),
29+ path(' feedback/' , views.feedback, name = ' feedback' ), # ✅ New URL
30+ ]
1831```
1932
2033
21- ## blogs/views.py
22- ``` python
34+
35+ ## blog/views.py
36+ ```
37+
2338
2439from django.shortcuts import render
2540
@@ -32,8 +47,20 @@ def about(request):
3247def contact(request):
3348 return render(request, 'pages/contact.html')
3449
50+ def feedback(request):
51+ success = False
52+ if request.method == 'POST':
53+ name = request.POST.get('name')
54+ email = request.POST.get('email')
55+ message = request.POST.get('message')
56+ print(f'Feedback from {name} ({email}): {message}')
57+ success = True
58+ return render(request, 'pages/feedback.html', {'success': success})
59+
60+
3561```
3662
63+
3764## blog/urls.py
3865``` python
3966from django.urls import path
@@ -50,6 +77,15 @@ urlpatterns = [
5077
5178## mysite/urls.py
5279``` python
80+ """
81+
82+ from django.contrib import admin
83+ from django.urls import path,include
84+
85+ urlpatterns = [
86+ path("admin/", admin.site.urls),
87+ path('', include('blog.urls')),
88+ ]
5389
5490
5591```
@@ -107,6 +143,55 @@ pages/
107143```
108144
109145
146+ ## 📁 Step 1: Update pages/urls.py
147+ ```python
148+
149+ from django.urls import path
150+ from . import views
151+
152+ urlpatterns = [
153+ path('', views.home, name='home'),
154+ path('about/', views.about, name='about'),
155+ path('contact/', views.contact, name='contact'),
156+ path('feedback/', views.feedback, name='feedback'), # ✅ New URL
157+ ]
158+
159+ ```
160+
161+
162+ ```python
163+ <!DOCTYPE html>
164+ <html>
165+ <head>
166+ <title>Feedback</title>
167+ </head>
168+ <body>
169+ <h1>Feedback Page</h1>
170+
171+ {% if success %}
172+ <p style="color: green;">Thank you for your feedback!</p>
173+ {% endif %}
174+
175+ <form method="post">
176+ {% csrf_token %}
177+ <label>Name:</label><br>
178+ <input type="text" name="name" required><br><br>
179+
180+ <label>Email:</label><br>
181+ <input type="email" name="email" required><br><br>
182+
183+ <label>Message:</label><br>
184+ <textarea name="message" rows="4" required></textarea><br><br>
185+
186+ <button type="submit">Submit</button>
187+ </form>
188+
189+ <br>
190+ <a href="/">Back to Home</a>
191+ </body>
192+ </html>
193+ ```
194+
110195### 🎯 Folder Setup
111196
112197```python
@@ -116,6 +201,9 @@ python manage.py startapp blog
116201```
117202
118203
204+
205+
206+
119207## 🔧 1. mysite/settings.py
120208Add 'blog' in INSTALLED_APPS:
121209
0 commit comments