When building a Django application, views are the heart of your web logic. They determine what users see when they visit a URL and how data is processed. Django gives you two main approaches to writing views: Function-Based Views (FBV) Class-Based Views (CBV) In this article, we’ll explore: Differences between FBV and CBV Pros and cons of each Real-world examples for when to use them By the end, you’ll know exactly which view type to pick for your Django projects. https://lnkd.in/gBdUY4-d
Devs3’s Post
More Relevant Posts
-
🚀 Day 1 with Flask – Backend Journey Begins! Today I officially started learning Flask, and it was an amazing experience diving into backend development! 🔥 Flask’s lightweight and simple structure makes web development much easier and beginner-friendly. Here’s what I learned today: ✅ Understanding the project structure (files & folders) ✅ Using pip to install required packages ✅ Serving static files (CSS, JS, images) ✅ Working with the debugger mode ✅ Creating dynamic routes ✅ Using redirect() properly ✅ Rendering HTML using templates ✅ Connecting URLs using url_for() ✅ Creating custom error handlers (like 404 pages) Small steps every day toward becoming a better backend developer 💻✨ #Flask #Python #WebDevelopment #BackendDevelopment #LearningJourney #ML
To view or add a comment, sign in
-
Django in 2026 — still relevant? Absolutely. I’ve put together a short PDF sharing my honest thoughts on: • Why Django remains one of the most structured and scalable web frameworks • Where it clearly outperforms newer tools • Where it needs serious modernization • And what I believe the modern Django stack should look like After 20+ years, Django’s biggest strength is still its structure, security, and maintainability. But the ecosystem is evolving — and Django must evolve with it. If you’re building serious backend systems or leading engineering teams, this conversation matters. Would love to hear your perspective. #Django #Python #BackendDevelopment #SoftwareArchitecture #WebDevelopment
To view or add a comment, sign in
-
Django Developers: Stop using .count() inside loops (Huge Performance Killer) I recently reviewed a backend codebase where API response time was ~2.8s for a simple dashboard. The culprit? N+1 queries + .count() inside loops Bad Code: for user in users: order_count = Order.objects.filter(user=user).count() Looks clean, right? But this runs 1 query per user If you have 100 users = 101 database queries. Optimized Approach: from django.db.models import Count users = User.objects.annotate(order_count=Count('order')) Now? Only ONE optimized query. Real Impact I saw: • Before: 2.8s API response • After: 320ms response • 88% performance improvement Backend rule I follow: “Never run queries inside loops if ORM can handle it.” 💡 Pro Tip: Use: select_related() → ForeignKey / OneToOne prefetch_related() → ManyToMany / Reverse FK annotate() → Aggregations without extra queries Are you still facing slow Django APIs in production? Comment “PERF” and I’ll share my Django performance checklist. #Python #Django #BackendDevelopment #SoftwareEngineering #APIDesign #SystemDesign
To view or add a comment, sign in
-
I’ve just open-sourced Boltdown, a Django-based web application designed to manage torrent workflows through a structured backend architecture. The project focuses on building a clean, modular Django setup that handles magnet link processing through a browser-based interface while maintaining a simple local deployment model. Technical highlights: 1. Backend built with Django (Python) 2. Structured app architecture with clear separation of concerns 3. Environment-based configuration 4. Designed for local execution and developer experimentation This project was primarily an exercise in backend system design, project structuring, and maintaining clean repository standards for open-source collaboration. Link: https://lnkd.in/dnwG3AqY #Django #Python #BackendDevelopment #SoftwareArchitecture #OpenSource #Git #WebDevelopment
To view or add a comment, sign in
-
WHY DJANGO REST_FRAMEWORK? DAY 9: THE BROWSABLE API (YOUR SECRET WEAPON) One of the biggest differences between Django and DRF is how you see your work. In standard Django, if you want to see if your logic works, you’re either looking at the Admin Panel or building a quick HTML template. Although, it gives a little more room for customization, it is still a bit of a detour. Enter the DRF Browsable API. heThe moment you create a view in DRF and navigate to the URL in your browser, you aren't just looking at raw JSON text. DRF renders a clean, interactive web page that allows you to: 1. GET data and see it beautifully formatted. 2. POST new data using a built-in form. 3. PUT/DELETE resources with the click of a button. It is essentially a live Sandbox for your backend. You can test your entire backend logic directly in the browser. For me, this was actually pretty fascinating, just seeing my Python logic turn into a functional interface that I could interact with, without writing a single line of CSS or HTML. It makes debugging feel less like a chore and more like a playground. Do you prefer testing your logic in the terminal (Shell) or are you like me and you need a visual interface to feel like it’s real? #APIs #webdevelopment #learninginpublic #learninpublic #whydjangorestframework #django #djangrestframework #python #webdev #backenddevelopment
To view or add a comment, sign in
-
Day 7: Don’t Let Broken Images Kill Your App! 🖼️ Mastering Static vs. Media Files Today is Day 7 of my 30-Day Django Mastery journey, and I’m closing out Week 1 by tackling one of the most common stumbling blocks in web development: Managing Assets. In Django, there is a strict "separation of concerns" between files you provide (CSS/JS) and files your users provide (Profile pictures/Resumes). The Key Difference: 1. Static Files (STATIC): These are the assets that make your site look good—your CSS, JavaScript, and Brand Logos. These are part of your source code. 2. Media Files (MEDIA): These are user-generated. Think of a candidate's profile picture or an uploaded PDF. These are dynamic and live outside your code logic. The Pro Configuration: To handle these like an engineer, you need to tell Django exactly where these live in your settings.py. Python # settings.py # For your CSS/JS/Logos STATIC_URL = 'static/' STATICFILES_DIRS = [BASE_DIR / 'static'] # For User Uploads (e.g., Profile Pics) MEDIA_URL = 'media/' MEDIA_ROOT = BASE_DIR / 'media' The "Production" Secret: collectstatic During development, Django’s runserver handles these easily. But in production (AWS, DigitalOcean, etc.), Django is not meant to serve files—it's too slow. We use the python manage.py collectstatic command to gather every single static asset into one folder so a high-performance web server (like Nginx or WhiteNoise) can serve them to users instantly. The Result? A lightning-fast application where images never break, and your backend stays focused on what it does best: processing data. Question for the community: What’s your preferred way to store media files in production? Amazon S3, Cloudinary, or local storage? Let’s talk strategy below! 👇 #Django #Python #WebDevelopment #30DaysOfCode #BackendEngineering #WebPerformance #FullStackDeveloper #CodingLife
To view or add a comment, sign in
-
-
🚀 Django Admin has been around for 20 years, but most teams still underestimate what it can really do. In a talk she gave at FOSDEM, Emmanuelle Delescolle – one of our own Squads team members, a long‑time Python/Django expert, and a member of both the PSF & DSF – breaks down the real power of Django Admin… and where its limitations start to show. She shares: • how Django Admin became a “framework inside a framework.” • why CRUD generation is still its biggest superpower • where customization becomes painful • a proposed architecture for the future of the Django Admin • how plugins can make all that possible If you work with Django or plan to, Emma’s insights on this architecture will bring a fresh perspective to your project.. 👉 Watch the full talk and learn directly from one of the experts shaping Django’s future. https://lnkd.in/dJBpuwSa 📩 And if you want to work with top-tier developers like Emma, reach out anytime: hello@squads.com #DjangoDevelopment #PythonCommunity #TechWebinars #EngineeringExcellence
To view or add a comment, sign in
-
-
🚀 Django 5.2’s Composite Primary Keys: A 20-Year Wait Is Over After years of workarounds, Django 5.2 finally introduces native support for composite primary keys — a major milestone for developers working with many-to-many relationships, time-series data, legacy schemas, and audit logs. In this insightful deep dive, Anas Issath explains: ✅ When composite keys make sense (junction tables, multi-tenant models, historical tracking) ✅ When to avoid them (tables requiring foreign-key references, core domain entities, Django Admin dependencies) ✅ How to implement them cleanly with models.CompositePrimaryKey ✅ Key limitations and migration pitfalls If you're modeling complex relationships or integrating with legacy systems, this feature can simplify your schema and strengthen data integrity — though it’s not a silver bullet. 🔗 Read the full article here: https://lnkd.in/gN4_nPYR Thanks a lot to Anas Issath for sharing such valuable knowledge with the community! #Django #Python #Databases #SoftwareEngineering #Backend #WebDevelopment #SystemDesign
To view or add a comment, sign in
-
Problem Wednesday. A small Django mistake that cost me hours. I was building a simple form in Django to save data into the database. Everything looked correct. The form rendered properly. No major errors. But when I clicked submit, nothing was saving. After checking models and views multiple times, I finally noticed the issue. I forgot to include method="POST" in the HTML form tag. Because of that, Django never received the POST request. The view logic was correct, but the request type was wrong. That moment helped me understand something important about backend development. Even when your Python and Django logic is correct, small frontend details can break the entire flow. Now, whenever form data does not save, I check three things immediately: 1. Is the form using POST 2. Is CSRF token included 3. Is request.method == "POST" handled correctly Understanding this improved my grasp of Django forms, request handling, and the overall request response cycle. If you are learning Django, debugging is not about writing more code. It is about tracing the flow carefully. 👉 What is one small mistake in Django that taught you a big lesson? 🔗 Helpful Resources Django Forms Documentation https://lnkd.in/gheCSvkC Django CSRF Protection https://lnkd.in/grEgWUc8 Django ModelForms Guide https://lnkd.in/gAQmRB5M #Python #Django #BackendDevelopment #WebDevelopment #LearningInPublic #StudentDeveloper #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
Day 6: Stop Copy-Pasting Your HTML! ⚡ Master Django Template Inheritance If you are manually adding your Navbar and Footer to every single page in your app, you are building a maintenance nightmare. Today is Day 6 of my 30-Day Django Mastery journey, and I’m focusing on the DRY (Don't Repeat Yourself) principle using Template Inheritance. Why this is a Game Changer: 1. Single Source of Truth: Change a link in your Navbar once, and it updates across your entire site instantly. 2. Clean Code: Your child templates stay focused only on their unique content, not the repetitive boilerplate. 3. Scalability: It makes building new pages 10x faster because the "frame" is already built. How it Works: I start with a base.html file that contains the skeleton (Head, Navbar, Footer). I use the {% block %} tag as a placeholder for where the unique page data will go. The Base Skeleton (base.html): <html> <body> {% include 'navbar.html' %} <main> {% block content %} {% endblock %} </main> {% include 'footer.html' %} </body> </html> The Child Page (post_detail.html): {% extends 'base.html' %} {% block content %} <h1>{{ post.title }}</h1> <p>{{ post.content }}</p> {% endblock %} By mastering this, you ensure your frontend architecture is just as scalable and organized as your backend. Question for the devs: Do you prefer using standard Django Templates, or are you moving toward headless setups with React/Vue? Let’s hear your thoughts! 👇 #Django #Python #WebDevelopment #30DaysOfCode #CleanCode #FullStackDeveloper #ProgrammingLife #BackendEngineering
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