𝗧𝗵𝗶𝘀 𝗜𝘀 𝗗𝗮𝘆 𝟲𝟯 𝗼𝗳 #𝟭𝟬𝟬𝗗𝗮𝘆𝘀𝗢𝗳𝗖𝗼𝗱𝗲 I continued my Python refresher and introduced Django. Yesterday, I covered Python basics. Today, I dove into functions and object-oriented programming \(OOP\) because these are essential for understanding Django. You define a function in Python using the def keyword. For example: - def greet\(name\): return f"Hello, \{name\}!" - print\(greet\("Haris"\)\) # Hello, Haris! Functions have powerful features: - You can assign default values to parameters - Use \*args to collect extra positional arguments into a tuple - Use \*\*kwargs to collect extra keyword arguments into a dictionary You can use these together. The order matters: regular args, \*args, \*\*kwargs. Python is fully object-oriented. You define classes and use \_\_init\_\_ as the constructor. - class Person: - def \_\_init\_\_\(self, name, age\): self.name = name, self.age = age - def introduce\(self\): return f"Hi, I'm \{self.name\} and I'm \{self.age\} years old." I also looked at how Django structures projects. A project is the entire web application, and you organize functionality into smaller units called apps. - Each app handles one specific part of your project - You create an app using python manage.py startapp posts This keeps your code modular and clean. Source: https://lnkd.in/g4YgFWMu
GyaanSetu WebDev’s Post
More Relevant Posts
-
Day 16 of my Python Full Stack journey. ✅ Today's topic: OOP — Object Oriented Programming. The biggest concept in Python so far. And the most important one for Django. Here's what clicked today: Everything in Python is an object. A class is just a blueprint for creating objects. Here's what I typed today: # Class = blueprint class Student: def __init__(self, name, marks): self.name = name self.marks = marks def result(self): if self.marks >= 50: return f"{self.name} — Pass ✅" return f"{self.name} — Fail ❌" # Object = actual instance built from blueprint s1 = Student("Punith", 88) s2 = Student("Rahul", 42) print(s1.result()) # Punith — Pass ✅ print(s2.result()) # Rahul — Fail ❌ Why this matters for Django: → Every Django Model is a class → Every Django View can be a class → Every Django Form is a class If you don't understand OOP — Django will feel like magic. If you do — Django will feel like logic. Today Django finally started making sense. 🤯 What concept made Django finally click for you? #PythonFullStack #Day16 #OOP #BuildingInPublic #100DaysOfCode #Bangalore
To view or add a comment, sign in
-
-
Day-129 📘 Python Full Stack Journey – Django Messages & Authentication Flow 🔐 Today I enhanced my Django application by implementing user feedback messages and complete authentication flow (Login & Logout). 🚀 🎯 What I learned today: 💬 Django Messages Framework Displayed success messages after signup using: messages.success(request, f'Account created for {username}!') Rendered messages in HTML using: {% if messages %} {% for message in messages %} <p style="color: green;">{{ message }}</p> {% endfor %} {% endif %} 💡 This improves user experience by giving instant feedback. 🔐 Login Using AuthenticationForm Used Django’s built-in AuthenticationForm Accessed form fields directly in template: {{ form.username }} {{ form.password }} Validated and authenticated users securely 🚪 Logout Functionality Implemented logout using: from django.contrib.auth import logout def logout_view(request): logout(request) return redirect('Login') Added logout route and link in UI ⚙️ Key Takeaways Improved user interaction with messages Built a complete authentication cycle (Signup → Login → Logout) Learned how Django handles sessions and user state This session made my application more user-friendly, secure, and complete. Excited to keep improving with protected routes and user-specific data next! 💻✨ #Django #Python #FullStackDevelopment #WebDevelopment #Authentication #Login #Logout #UserExperience #CodingJourney #LearningToCode #Upskilling #ContinuousLearning
To view or add a comment, sign in
-
-
Day 18 of my Python Full Stack journey. ✅ Today's topic: Inheritance — one of the most powerful concepts in OOP. Instead of writing the same code twice — you inherit it from a parent class. Here's what I typed today: # Parent class class Person: def __init__(self, name, age): self.name = name self.age = age def introduce(self): return f"Hi, I'm {self.name}, {self.age} years old." # Child class — inherits from Person class Student(Person): def __init__(self, name, age, course): super().__init__(name, age) # inherits parent __init__ self.course = course # Method overriding — redefining parent method def introduce(self): return f"Hi, I'm {self.name}. I study {self.course}." s1 = Student("Punith", 24, "Python Full Stack") print(s1.introduce()) # Hi, I'm Punith. I study Python Full Stack. 3 things that clicked today: → super() calls the parent class — no need to rewrite __init__ → Child class can override any parent method → Child class can also add brand new methods of its own Why this matters for Django: → Django's Model class is a parent class → When you write 'class Student(models.Model)' — you are inheriting from Django's Model → That one line gives your class database superpowers #PythonFullStack #Day18 #Inheritance #OOP #BuildingInPublic #100DaysOfCode #Bangalore
To view or add a comment, sign in
-
-
5 books. 6 database trips. That's your Django app bleeding performance. Most of the time we never notice the N+1 problem — until their app slows down under real data. Here's the fix explained as a story (swipe through) 👇 𝗦𝗹𝗶𝗱𝗲 𝟭 — You have 5 books. Each has an author. Simple. 𝗦𝗹𝗶𝗱𝗲 𝟮 — Without optimization: Django makes 6 separate DB trips. One per book. Painful. 𝗦𝗹𝗶𝗱𝗲 𝟯 — select_related() fixes it with a single JOIN. 1 trip. Everything together. 𝗦𝗹𝗶𝗱𝗲 𝟰 — But JOIN breaks with tags — Book 1 repeats 3 times. Messy. 𝗦𝗹𝗶𝗱𝗲 𝟱 — prefetch_related() makes 2 smart trips. Python glues them in memory. 𝗦𝗹𝗶𝗱𝗲 𝟲 — The rule: ONE thing → select_related. MANY things → prefetch_related. That's it. Two methods. One simple rule. #Django #Python #WebDevelopment #BackendDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
Day-122 📘 Python Full Stack Journey – Django Admin Customization & Form Feedback Today I explored how to enhance data presentation in Django Admin and improve user experience after form submission. 🚀 🎯 What I learned today: 📊 Admin Panel – Data Table View Customized Django Admin using ModelAdmin Displayed specific fields in a table format using: class ContactAdmin(admin.ModelAdmin): list_display = ('user_name', 'email_id', 'phone_number') This made the admin panel more structured and easier to manage data 💬 Popup / Response Page After Form Submission Created a popup (response) page to show feedback after form submission Updated views.py to: Validate and save form data Redirect or render a success page after submission if form.is_valid(): form.save() return render(request, 'popup.html') 💡 This improves user experience by confirming that the form was successfully submitted. This session helped me understand how to make applications more user-friendly and organized, both on the admin side and user-facing side. Step by step, building more complete Django applications! 💻✨ #Django #Python #FullStackDevelopment #WebDevelopment #Backend #AdminPanel #Forms #UIUX #CodingJourney #LearningToCode #Upskilling #ContinuousLearning
To view or add a comment, sign in
-
-
🚀 Build Powerful APIs with Python (Django REST Framework & FastAPI) In this post, I've broken down how to create APIs using two of the most popular Python frameworks: Django REST Framework and FastAPI—in a simple, algorithmic, and visual way. 🔹 What's inside the post? Step-by-step API development flow for both frameworks Clear algorithmic approach (from setup -> models -> endpoints -> testing) Practical code snippets to get started quickly Side-by-side comparison of DRF vs FastAPI Tips on when to use each framework 🔹 Django REST Framework Best for large, database-driven applications where you need a complete ecosystem with authentication, ORM, and scalability. 🔹 FastAPI Perfect for high-performance APIs, microservices, and modern apps with automatic validation and interactive docs. 💡 Key Takeaway: Both frameworks are powerful—choose DRF for full-scale applications and FastAPI for speed and lightweight performance. 🔥 Whether you're preparing for interviews or building real-world projects, mastering these tools is essential for every backend developer. #Python #API #Django #FastAPI #BackendDevelopment #WebDevelopment #SoftwareEngineering 🚀
To view or add a comment, sign in
-
-
🚀 Day 17 – Python API Integration Today I explored the power of Django REST Framework and how it simplifies building RESTful APIs in Python. 🔹 Key takeaways: Understood how Django REST Framework extends Django to build APIs efficiently Created a Django project and app structure (countryapi, countries) Built a Model (Country) to represent data Learned how Serializers convert Django models into JSON Used ModelViewSet to handle CRUD operations automatically Configured DefaultRouter to generate API endpoints 🔹 Implemented API endpoints: GET → Retrieve countries POST → Create new country PUT / PATCH → Update data DELETE → Remove data 💡 What stood out: Django REST Framework reduces a lot of boilerplate by providing built-in tools for serialization, routing, and request handling — making API development faster and more structured. 📌 This is a big step forward in building production-ready backend systems. #Python #DataEngineering #Django #DjangoRESTFramework #APIs #BackendDevelopment #LearningJourney #selfLearning
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development