🔥 90 Days of Python Full Stack – Day 51 Django Templates & Dynamic Rendering Today was about bringing the backend to life. After creating models and performing ORM queries, the next step is showing that data in the browser — dynamically. This is where Django Templates come in. 🔹 What I Learned ✅ How Django templates work ✅ Template syntax: {{ variable }} for dynamic data {% for %} loops {% if %} conditions ✅ Passing data from views → templates ✅ Using render() to send context data ✅ Displaying database records dynamically ✅ Template inheritance using base.html 🔄 Data Flow I Practiced Model → View → Template → Browser Python def product_list(request): products = Product.objects.all() return render(request, "products.html", {"products": products}) And inside the template: HTML {% for product in products %} <li>{{ product.name }} - {{ product.price }}</li> {% endfor %} That moment when database data appears in the UI 🔥 💡 Why This Is Important Now the app is: ✔ Not static ✔ Not hard-coded ✔ Fully dynamic ✔ Connected to real database data This is the core of real-world web applications. Day 51 complete. Backend + Frontend communication unlocked #90DaysOfPython #Django #FullStackDevelopment #LearningInPublic
Django Templates & Dynamic Rendering with Python
More Relevant Posts
-
🔥 90 Days of Python Full Stack – Day 56 DRF ViewSets, Routers & Full CRUD APIs Today I upgraded my APIs from basic endpoints to fully structured RESTful services using Django REST Framework. Instead of writing separate views for every operation, I learned how to build complete CRUD APIs in a clean, scalable way. 🔹 What I Learned ✅ What are ViewSets in DRF ✅ Using ModelViewSet ✅ Handling full CRUD automatically: GET → List & Retrieve POST → Create PUT / PATCH → Update ✅ DELETE → Destroy ✅ Using Routers to auto-generate URLs ✅ RESTful API structure ✅ Testing endpoints in Postman 🔄 Practical Structure I Built Python from rest_framework import viewsets from .models import Product from .serializers import ProductSerializer class ProductViewSet(viewsets.ModelViewSet): queryset = Product.objects.all() serializer_class = ProductSerializer Using Router: Python from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register(r'products', ProductViewSet) Now the API automatically supports: /api/products/ /api/products/1/ With full CRUD operations. 💡 Why This Is Important Now my backend: ✔ Follows industry REST standards ✔ Scales easily ✔ Reduces repetitive code ✔ Supports frontend frameworks & mobile apps This is how real production APIs are structured. Day 56 complete. My backend is now properly RESTful and scalable #90DaysOfPython #DjangoRESTFramework #APIDevelopment #BackendDevelopment #FullStackJourney
To view or add a comment, sign in
-
-
I spent 6 years starting Python backend projects the same way: Create folder structure Wire up config management Write the Dockerfile Set up CI/CD Add test boilerplate Configure auth Write a README 45 minutes of muscle memory before writing a single line of actual business logic. JavaScript developers don't have this problem. They run npx create-next-app and start building. Python never had the same experience. So I built snapstack -- the create-next-app for Python. One command. Production-ready project. Zero manual edits needed. pip install snapstack && snapstack create my-api What you get: FastAPI, Django, or Flask -- your choice Working health check endpoint + passing test on first run Dockerfile + docker-compose with health checks GitHub Actions CI with lint + test pipeline JWT authentication (optional) SQLAlchemy 2 with async support pyproject.toml with typed config, dev extras, and ruff .pysnap.json manifest for future snapstack update upgrades Under the hood: 59 tests with full coverage Manifest-driven template engine (add a framework without touching core code) Plugin system via Python entry points Community template registry Everything is open source, MIT licensed, and available on PyPI today. If you've ever felt the friction of starting a new Python project, I'd love your feedback. What would you want snapstack to scaffold next? GitHub: https://lnkd.in/dk8268nb PyPI: https://lnkd.in/dndVAYeR #Python #OpenSource #DeveloperTools #FastAPI #Django #Flask #BackendDevelopment
To view or add a comment, sign in
-
𝐁𝐮𝐢𝐥𝐝𝐢𝐧𝐠 𝐖𝐞𝐛 𝐀𝐩𝐩𝐬 𝐢𝐧 𝐌𝐢𝐧𝐮𝐭𝐞𝐬: 𝐀𝐧 𝐈𝐧𝐭𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧 𝐭𝐨 𝐒𝐭𝐫𝐞𝐚𝐦𝐥𝐢𝐭. 𝐀𝐬 Python developers, we often build powerful data models and scripts, but sharing them with non-technical users can be a headache. Building a full web application using Django or Flask just to showcase a simple dashboard often feels like overkill. This is exactly where 𝐒𝐭𝐫𝐞𝐚𝐦𝐥𝐢𝐭 changes the game. 𝐒𝐭𝐫𝐞𝐚𝐦𝐥𝐢𝐭 is an open-source Python library that turns data scripts into shareable web apps in minutes. It requires absolutely zero front-end experience. No HTML, CSS, or JavaScript is needed—just pure Python. It automatically handles the UI updates as users interact with your widgets. 𝐇𝐨𝐰 𝐭𝐨 𝐆𝐞𝐭 𝐒𝐭𝐚𝐫𝐭𝐞𝐝 (𝐈𝐧𝐬𝐭𝐚𝐥𝐥𝐚𝐭𝐢𝐨𝐧):- • Open your Command Prompt or Terminal. • Run this simple command: pip install streamlit • To verify the installation and see a built-in demo, run: streamlit hello 𝐀 𝐐𝐮𝐢𝐜𝐤 𝐄𝐱𝐚𝐦𝐩𝐥𝐞:- Create a new Python file named app.py and add this code: import streamlit as st st.title("User Greeting Dashboard") user_name = st.text_input("Enter your name:") if user_name: st.success(f"Hello, {user_name}! Welcome to the platform.") else: st.write("Please enter a name, like 'Hamza' or 'Fatima'.") To launch your new web app, go to your terminal and type: streamlit run app.py Conclusion:- Streamlit drastically reduces the time to market for data applications. It allows us to focus entirely on the backend logic and data processing rather than getting bogged down by UI components. It is a must-have tool in any modern Python stack. Special thanks to my mentor Mian Ahmad Basit Ahmad Basit for the continued guidance. #MuhammadAbdullahWaseem #Nexskill #Streamlit #PythonProgramming #Pakistan
To view or add a comment, sign in
-
🧠 Django ORM + DRF: N+1 query problem in APIs While building REST APIs for my job board, restaurant, and task manager projects with Django and Django REST Framework, I faced the classic N+1 query problem. In short: One request from the frontend But the backend hits the database many times because of ForeignKey / ManyToMany relations Simple example: # Bad: N+1 problem orders = Order.objects.all() for order in orders: print(order.customer.name) # each loop hits the DB The fix is to use: # Good: one query with join orders = Order.objects.select_related("customer") I apply the same idea inside my DRF viewsets to optimize API performance: class OrderViewSet(ModelViewSet): queryset = Order.objects.select_related("customer") serializer_class = OrderSerializer These small optimizations make a big difference when the data grows and help keep the API fast and scalable. I’m trying to apply these patterns step by step in my Django & DRF projects and keep learning more about backend performance. 🚀 #Django #DjangoRESTFramework #Python #BackendDevelopment #APIs #Performance
To view or add a comment, sign in
-
-
Added to AGENTS.MD in a frontend + Django Python API project. Simple Codex instructions like creating a feature or writing PR comments were consuming ~30% of context memory per call. These notes brought that down to roughly 10–17%. here it goes : To reduce context size and memory usage, follow these rules when analyzing the repository: ### Step 1 — Diff First 1. Inspect the **git diff** before performing any repository exploration. 2. List the files modified in the PR. ### Step 2 — Targeted Analysis 3. Only open files that appear in the diff. 4. Do NOT explore the repository before analyzing the diff. 5. Do NOT read the entire repository. ### Step 3 — Limited Context Expansion 6. If additional context is required, use **repository search first**. 7. Only open additional files if strictly necessary to understand the change. 8. Any file opened that is not part of the diff must be **explicitly justified**. ### Step 4 — Exploration Limits 9. Maximum automatic file reads: **5 files**. 10. Prefer reading **small sections of files** instead of entire files. ### Step 5 — PR Review Output 11. After minimal exploration, generate the PR review comment. 12. The review must be written in a **human-like format using Markdown**. 13. Respect task scope. If the task is backend-only, do not inspect frontend code and vice versa.
To view or add a comment, sign in
-
WSGI vs ASGI. If you've used Django, Flask, or FastAPI, you've probably seen these terms — but do you really know what they mean? I recently explored how Python web servers actually communicate with applications and why modern frameworks are moving from WSGI to ASGI. I wrote a short article explaining: • Difference between WSGI and ASGI • Django's hybrid architecture • FastAPI's async-first design • How request handling actually works under the hood #Python #Backend #FastAPI #Django
To view or add a comment, sign in
-
Django vs FastAPI — Which One Is More Pythonic and Faster? (Engineering View) When engineers choose a backend framework, the real questions are simple: • Which framework is more Pythonic? • Which one is faster under load? • Which one follows Python behavior more naturally? Let’s look at it from an engineering perspective. 🧠 1. Pythonic Design FastAPI feels very close to writing normal Python. It relies heavily on modern Python features: Type hints Async/await Clean function-based APIs Example: @app.get("/users/{id}") async def get_user(id: int): return {"id": id} Your Python types become validation, documentation, and API schema automatically. Django, however, follows a framework-centric design with: class-based views Django ORM patterns configuration-heavy structures This makes Django powerful but sometimes less close to plain Python behavior. ✅ Result: FastAPI feels more Pythonic. ⚡ 2. Performance FastAPI is built on ASGI architecture. That means: async I/O high concurrency non-blocking request handling Under high traffic, FastAPI can handle significantly more requests per second. Django traditionally runs on WSGI, which is mostly synchronous. It’s extremely stable but not optimized for high-concurrency APIs by default. ✅ Result: FastAPI is usually faster for API workloads. ⚙️ 3. Engineering Philosophy FastAPI focuses on: • modern API architecture • microservices • async performance • minimal abstraction Django focuses on: • full web applications • rapid development • batteries-included ecosystem • admin panel, ORM, authentication 🎯 Engineering Takeaway If you want: ✔ Clean Python design ✔ High-performance APIs ✔ Modern async architecture ➡ FastAPI is often the better engineering choice. If you want: ✔ A complete web framework ✔ Built-in admin panel ✔ ORM and authentication ready ➡ Django remains one of the most productive frameworks. Both frameworks are excellent. The best choice depends on the system you are designing. #Python #FastAPI #Django #BackendEngineering #SoftwareArchitecture #APIDesign
To view or add a comment, sign in
-
-
Django vs FastAPI — Which One Is More Pythonic and Faster? (Engineering View) When engineers choose a backend framework, the real questions are simple: • Which framework is more Pythonic? • Which one is faster under load? • Which one follows Python behavior more naturally? Let’s look at it from an engineering perspective. 🧠 1. Pythonic Design FastAPI feels very close to writing normal Python. It relies heavily on modern Python features: Type hints Async/await Clean function-based APIs Example: @app.get("/users/{id}") async def get_user(id: int): return {"id": id} Your Python types become validation, documentation, and API schema automatically. Django, however, follows a framework-centric design with: class-based views Django ORM patterns configuration-heavy structures This makes Django powerful but sometimes less close to plain Python behavior. ✅ Result: FastAPI feels more Pythonic. ⚡ 2. Performance FastAPI is built on ASGI architecture. That means: async I/O high concurrency non-blocking request handling Under high traffic, FastAPI can handle significantly more requests per second. Django traditionally runs on WSGI, which is mostly synchronous. It’s extremely stable but not optimized for high-concurrency APIs by default. ✅ Result: FastAPI is usually faster for API workloads. ⚙️ 3. Engineering Philosophy FastAPI focuses on: • modern API architecture • microservices • async performance • minimal abstraction Django focuses on: • full web applications • rapid development • batteries-included ecosystem • admin panel, ORM, authentication 🎯 Engineering Takeaway If you want: ✔ Clean Python design ✔ High-performance APIs ✔ Modern async architecture ➡ FastAPI is often the better engineering choice. If you want: ✔ A complete web framework ✔ Built-in admin panel ✔ ORM and authentication ready ➡ Django remains one of the most productive frameworks. Both frameworks are excellent. The best choice depends on the system you are designing. #Python #FastAPI #Django #BackendEngineering #SoftwareArchitecture #APIDesign
To view or add a comment, sign in
-
-
Writing a Django query does not mean it hits the database! Writing a Django query and hitting the database are two different things. The ORM makes it easy to forget the difference between these. Here's what actually happens: 1. When a QuerySet is written, Django builds a query object internally. 2. This has no SQL. No database connection. Just a description of what data is needed. 3. This description can be chained, filtered, sliced, and passed around as required. Still no database hit. 4. The database is only contacted at the moment of evaluation, when Python actually needs the data. This is powerful when used intentionally. Build a complex query across multiple functions, evaluate once, pay the DB cost once! This can backfire too! A QuerySet evaluated inside a loop, once per iteration, is the N+1 problem. Takeaway: -> Efficiency: Chain and pass QuerySets, zero DB cost until evaluation -> Danger: Evaluation inside loops fires one query per row silently -> Control: Knowing evaluation points is the foundation of ORM performance I’m deep-diving into Django internals and performance. Do follow along and tell your experiences in comments. #Python #Django #DjangoInternals #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
🔥 90 Days of Python Full Stack – Day 52 Django Forms & Handling User Input Today was about making the application interactive. Until now, users could only view data. Now they can submit data. This is where real web application behavior begins. 🔹 What I Learned ✅ Creating forms using forms.py ✅ Using forms.Form and forms.ModelForm ✅ Form fields like: CharField EmailField IntegerField PasswordInput ✅ Handling GET vs POST requests ✅ Validating forms using form.is_valid() ✅ Accessing cleaned data ✅ Saving form data to the database ✅ Understanding CSRF protection 🔄 Practical Flow I Practiced User fills form Browser sends POST request View validates data Data gets saved to database Success response returned Example: Python def contact_view(request): if request.method == "POST": form = ContactForm(request.POST) if form.is_valid(): form.save() else: form = ContactForm() return render(request, "contact.html", {"form": form}) This connects frontend forms directly to backend logic. 💡 Why This Is Important Now the app can: ✔ Accept user input ✔ Create new records ✔ Validate data securely ✔ Prevent malicious submissions This is the foundation for: Registration systems Login systems Contact forms Product creation forms Day 52 complete. My Django app is no longer static — it interacts with users #90DaysOfPython #Django #FullStackDevelopment #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
Explore related topics
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