🎯 𝐃𝐚𝐲 𝟒 𝐨𝐟 𝟓𝟎: 𝐃𝐣𝐚𝐧𝐠𝐨'𝐬 "𝐁𝐚𝐭𝐭𝐞𝐫𝐢𝐞𝐬 𝐈𝐧𝐜𝐥𝐮𝐝𝐞𝐝" 𝐏𝐡𝐢𝐥𝐨𝐬𝐨𝐩𝐡𝐲 𝐢𝐧 𝐀𝐜𝐭𝐢𝐨𝐧 I finally understand why experienced developers swear by Django. Today it clicked — this isn't just a framework. It's a fully loaded toolkit that lets you build instead of configure. Zero custom authentication. Zero manual database queries. Zero boilerplate infrastructure. Just results. 𝐖𝐡𝐚𝐭 𝐈 𝐁𝐮𝐢𝐥𝐭: 🛠️ A fully functional blog system — admin panel, public-facing website, and styled templates. All in one day. That's Django's superpower. 𝐓𝐡𝐞 "𝐁𝐚𝐭𝐭𝐞𝐫𝐢𝐞𝐬 𝐈𝐧𝐜𝐥𝐮𝐝𝐞𝐝" 𝐌𝐨𝐦𝐞𝐧𝐭: 🔋 Most frameworks hand you parts and say "good luck." Django hands you a fully assembled vehicle. I registered three models — Author, Category, Post — with filtering, searching, and bulk operations in 𝒖𝒏𝒅𝒆𝒓 𝟓𝟎 𝒍𝒊𝒏𝒆𝒔 𝒐𝒇 𝒄𝒐𝒅𝒆. No custom dashboard. No UI library. No authentication system to wire up. Django's built-in admin is production-grade straight out of the box. 𝐃𝐣𝐚𝐧𝐠𝐨 𝐓𝐞𝐦𝐩𝐥𝐚𝐭𝐞 𝐋𝐚𝐧𝐠𝐮𝐚𝐠𝐞 (𝐃𝐓𝐋): 📝 Clean. Simple. Powerful. {% 𝘧𝘰𝘳 𝘱𝘰𝘴𝘵 𝘪𝘯 𝘱𝘰𝘴𝘵𝘴 %} → 𝘕𝘰 𝘑𝘢𝘷𝘢𝘚𝘤𝘳𝘪𝘱𝘵 𝘭𝘰𝘰𝘱𝘴 {{ 𝘱𝘰𝘴𝘵.𝘢𝘶𝘵𝘩𝘰𝘳.𝘯𝘢𝘮𝘦 }} → 𝘕𝘰 𝘈𝘗𝘐 𝘤𝘢𝘭𝘭𝘴 {% 𝘶𝘳𝘭 '𝘣𝘭𝘰𝘨:𝘱𝘰𝘴𝘵_𝘥𝘦𝘵𝘢𝘪𝘭' %} → 𝘕𝘰 𝘩𝘢𝘳𝘥𝘤𝘰𝘥𝘦𝘥 𝘜𝘙𝘓𝘴 {{ 𝘥𝘢𝘵𝘦|𝘥𝘢𝘵𝘦:"𝘔 𝘥, 𝘠" }} → 𝘕𝘰 𝘥𝘢𝘵𝘦 𝘭𝘪𝘣𝘳𝘢𝘳𝘪𝘦𝘴 One base template with {% block %} tags and every page inherits consistent structure 𝒂𝒖𝒕𝒐𝒎𝒂𝒕𝒊𝒄𝒂𝒍𝒍𝒚. 𝐖𝐡𝐚𝐭'𝐬 𝐀𝐜𝐭𝐮𝐚𝐥𝐥𝐲 𝐈𝐦𝐩𝐫𝐞𝐬𝐬𝐢𝐯𝐞: 💡 Static files? 𝑩𝒖𝒊𝒍𝒕-𝒊𝒏. Templates? 𝑩𝒖𝒊𝒍𝒕-𝒊𝒏. Admin panel? 𝑩𝒖𝒊𝒍𝒕-𝒊𝒏. Authentication? 𝑩𝒖𝒊𝒍𝒕-𝒊𝒏. ORM? 𝑩𝒖𝒊𝒍𝒕-𝒊𝒏. By Day 3 I had models and a CLI. By Day 4 I have a publishable web application. 𝑻𝒉𝒂𝒕'𝒔 𝒕𝒉𝒆 𝒎𝒂𝒈𝒊𝒄 𝒐𝒇 𝒐𝒑𝒊𝒏𝒊𝒐𝒏𝒂𝒕𝒆𝒅 𝒇𝒓𝒂𝒎𝒆𝒘𝒐𝒓𝒌𝒔. 𝐓𝐡𝐞 𝐑𝐞𝐚𝐥 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲: 🚀 Django's philosophy is quietly powerful — move fast because the fundamentals are already solved. You're not reinventing wheels. You're shipping products. Day 5 incoming. More depth, more complexity. 💪 #Django #WebDevelopment #Python #BatteriesIncluded #50DayChallenge #LearningInPublic #Backend #FullStack #DeveloperJourney #PythonDeveloper
More Relevant Posts
-
DAY 21: PAGINATION in Django Efficiently handling large datasets like a pro! When building scalable web applications, loading all records at once isn’t just inefficient—it can break performance and ruin user experience. That’s where Pagination becomes essential 👇 🔹 What is Pagination? Pagination is the process of dividing large datasets into smaller, manageable chunks (pages). Instead of loading 1000 records, you display only a few (like 10–20) per request. 🔹 Why Pagination Matters? ✅ Reduces server load ✅ Improves response time ✅ Enhances UI/UX clarity ✅ Enables smooth navigation (Next / Previous) ✅ Prevents browser lag & crashes 🔹 How Pagination Works (Flow) 👉 Request → QuerySet → Paginator → Page Object → Response Only the required subset of data is fetched from the database using efficient queries (LIMIT & OFFSET). 🔹 Using Paginator in Django Django provides a built-in Paginator class to handle pagination easily: ✔ Splits QuerySets ✔ Handles invalid pages gracefully ✔ Provides navigation helpers like has_next, has_previous 🔹 Class-Based Views (CBV) Magic ✨ With CBVs, pagination becomes even simpler: 👉 Just add paginate_by = 5 Django automatically handles: ✔ Page object (page_obj) ✔ Pagination state (is_paginated) ✔ Template integration 🔹 Key Attributes You Should Know 📌 has_next → Is next page available? 📌 has_previous → Is previous page available? 📌 number → Current page number 📌 paginator.num_pages → Total pages 🔹 Best Practices for Developers ✔ Keep 5–20 items per page ✔ Combine with search & filters ✔ Optimize queries using select_related / prefetch_related ✔ Add database indexing for faster queries ✔ Use clean UI components (Bootstrap pagination) 🔹 Real-World Use Cases 🛒 E-commerce product listings 📝 Blog posts 📊 Admin dashboards 📱 Social media feeds ⚠️ Common Mistakes to Avoid ❌ Loading all records at once ❌ Using too many items per page ❌ Ignoring query optimization ❌ Not handling invalid page numbers ❌ Missing ordering in QuerySets 🔹 Advanced Insight 💡 For large-scale applications: 👉 Page-based pagination may become slow 👉 Prefer cursor-based pagination (used in modern apps) Frameworks like Django REST Framework provide advanced pagination styles for APIs. ⭐ Key Takeaway Pagination is not just a feature—it’s a performance strategy.
To view or add a comment, sign in
-
-
📘 Day 84: Django – Templates & Dynamic Data 🔹 What are Templates? • Templates are used to create the frontend (HTML pages) in Django • They display data sent from the backend • Helps separate design from logic 🔸 Templates Folder Setup • A templates folder is created inside the app • This folder stores all HTML files 🔹 Important Step: • Must register the templates folder in settings.py (DIRS section) • Without this → Django cannot find HTML files 🔸 HTML Page Creation • Create HTML files inside the templates folder • These act as the UI of the application 🔹 Key Idea: • HTML is static • Django makes it dynamic 🔸 Rendering Templates • To display an HTML page → use render() in views 🔹 Flow: • URL → View → Template 💡 render(): • Connects backend (views) with frontend (HTML) • Sends data to HTML 🔸 Django Variables {{ }} • Used to display dynamic data in HTML 🔹 Key Points: • Written inside {{ }} • Values come from views (dictionary data) • Keys in dictionary = variables in template 💡 Example Concept: • Backend sends → name = "Adam" • Frontend displays → {{ name }} 🔸 Passing Data to Templates • Data is passed as a dictionary from views 🔹 Key Points: • Keys → variable names • Values → actual data • Can pass directly or using a variable 🔸 Django Template Tags {% %} • Used to add logic inside HTML 🔹 Used For: • Conditions (if, else) • Loops (for) 🔸 Conditional Rendering • Templates can check conditions like Python 🔹 Key Points: • {% if %}, {% elif %}, {% else %} • Must end with {% endif %} 💡 Example Concept: • If age ≥ 18 → show eligible • Else → show not eligible 🔸 Execution Flow User opens URL URL calls view View sends data Template displays data ✨ Today you learned: • What templates are and how they work • How to connect HTML with Django using render() • How to use dynamic variables {{ }} • How to use logic inside HTML with {% %} This is where Django becomes powerful—combining backend + frontend seamlessly 🚀 #Django #Python #WebDevelopment #Frontend #BackendDevelopment #Day84 #Templates #FullStack #CodingJourney
To view or add a comment, sign in
-
🚀 Alternatives to Anvil https://lnkd.in/eZUtz9GZ 🔍 What is Anvil Anvil is a platform that allows developers to build full-stack web apps using pure Python—no JavaScript required. It combines UI design, backend logic, and database access in one environment, enabling rapid development. ⚙️ Function of Anvil • Drag-and-drop UI builder • Python-based backend + frontend • Built-in database and hosting • API integrations • One-click deployment It acts as a Python-first full-stack development platform. ✅ Pros • No need for JavaScript • Fast prototyping • Integrated hosting + database • Beginner-friendly • Strong Python ecosystem ❌ Cons • Limited flexibility vs full frameworks • Vendor lock-in risk • Scaling constraints • Less control over infrastructure • Smaller ecosystem than mainstream stacks 💰 Cost • Free tier available • Paid plans: ~$12–$99/month • Enterprise pricing for teams 🔁 Alternatives to Anvil 1️⃣ Streamlit Description: Python app builder Function: Build data apps quickly Uniqueness: Minimal code UI Pro: Fast prototyping Con: Limited frontend control Cost: Free + cloud 2️⃣ Dash Description: Python dashboard framework Function: Build analytical apps Uniqueness: Plotly integration Pro: Highly customizable Con: More code required Cost: Free 3️⃣ Retool Description: Low-code platform Function: Build internal apps Uniqueness: API-first approach Pro: Enterprise-ready Con: Not Python-native Cost: Paid 4️⃣ Bubble Description: Visual app builder Function: Full-stack apps Uniqueness: No-code ecosystem Pro: Beginner-friendly Con: Performance limits Cost: Subscription 5️⃣ FlutterFlow Description: Flutter-based builder Function: Mobile/web apps Uniqueness: Code export Pro: Cross-platform Con: Learning curve Cost: Free + paid 6️⃣ Appsmith Description: Open-source platform Function: Build internal tools Uniqueness: Self-hostable Pro: Flexible Con: Setup required Cost: Free 7️⃣ ToolJet Description: Open-source builder Function: Internal apps Uniqueness: Lightweight Pro: Easy deployment Con: Limited UI polish Cost: Free 8️⃣ Next.js Description: Full-stack JS framework Function: Build scalable apps Uniqueness: SSR + API routes Pro: High performance Con: Requires JS knowledge Cost: Free 9️⃣ Django Description: Full-stack Python framework Function: Build robust web apps Uniqueness: Batteries-included Pro: Highly scalable Con: Slower setup Cost: Free 🔟 Supabase Description: Firebase alternative Function: Backend + DB + auth Uniqueness: Open-source backend Pro: Fast backend setup Con: Needs frontend pairing Cost: Free + paid 💡 Insight Anvil simplifies development by abstracting complexity. But alternatives fall into 3 categories: • Python-first → Streamlit, Dash • Low/No-code → Bubble, Retool • Full-stack frameworks → Django, Next.js The trade-off: Speed vs Control 🔖 #Tags #Anvil #Python #LowCode #NoCode #WebDevelopment #AppBuilder #FutureOfWork #AItools
To view or add a comment, sign in
-
-
Just shipped something I'm proud of. After completing my Django course at ITI Information Technology Institute (ITI), our team built CareLink — a full-stack clinic management system from scratch. Not a tutorial project. A real system with real complexity. What CareLink actually does: A doctor walks in, opens their dashboard, and sees their entire day — who's waiting, how long they've been waiting, pending appointment requests they can confirm or reject in one click, their completion rate, no-show stats, and their weekly performance charts. All live. All connected to a real backend. A receptionist manages the queue, checks patients in, reschedules on behalf of patients with a full audit trail of every change — who changed what, when, and why. A patient books a slot, picks a doctor, selects a date, sees only genuinely available time slots based on the doctor's weekly schedule, buffer times, and existing bookings — no double booking, no overlap, no race conditions. An admin gets the full picture — users, roles, analytics, and CSV exports. The technical side that kept us up at night: Slot generation engine — calculates available slots dynamically from weekly schedules + exceptions + buffer time + existing bookings. Prevents double-booking at the database level with select_for_update() inside atomic transactions. Analytics API — no-show rates, avg wait time, appointment trends over 7/30/90 days, status breakdowns, patient growth — all computed server-side. Full appointment lifecycle — REQUESTED → CONFIRMED → CHECKED_IN → COMPLETED, with business rules enforced at every transition. You can't complete an appointment without a consultation record. You can't go back to REQUESTED after confirmation. EMR Lite — doctors fill in diagnosis, clinical notes, prescriptions, and test requests per consultation. Patients can read their summaries. Receptionists cannot see medical notes. Audit trail — every reschedule logs old datetime, new datetime, who changed it, and why. The stack: Backend: Django · Django REST Framework · MySQL · Token Auth · Custom permissions per role Frontend: Angular 17 · Bootstrap 5 · CSS-only charts · Signal-based state management · URL-synced filters & pagination The team that built this: This was a real team effort and I'm proud of every person who pushed through the hard parts with me. Amir Alsayed , Mohammed Elazzazy , Hager Nofal🇵🇸🔻 , doniaa mohamed See it running 👇 (video attached) Frontend demo => https://lnkd.in/dF646-sh Backend demo=> https://lnkd.in/dY3Hsmnu #Django #Angular #ITI #Python #FullStack #WebDevelopment #Healthcare #TeamWork #CareLink
To view or add a comment, sign in
-
📘 Day 85: Django – Loops, Multiple Pages & Template Inheritance 🔹 For Loop in Django Templates • Django allows looping inside HTML using template tags • Used to display multiple values dynamically 🔸 Key Points: • Written using {% for %} and {% endfor %} • Works with lists passed from views • Iterator prints each value using {{ }} 💡 Concept: • Backend sends list → Template loops → Displays each item 👉 Example covered: passing names list and displaying each name 🔸 Multiple Data with Loops • You can pass multiple lists (like name, place) • Each loop must have its own {% endfor %} 🔹 Key Idea: • One loop = one dataset 🔸 Multiple HTML Pages • Each HTML page needs its own function in views.py • Each function is mapped in urls.py 🔹 Key Points: • One view = one page • URL path decides which page loads 💡 Example: • Home → / • About → /ab • Contact → /co 🔸 Template Inheritance • Used to avoid repeating code (like navbar, footer) • One main file (parent) → other pages (child) extend it 🔹 Base Template (base.html) • Contains common structure (navbar, layout) • Uses blocks like: • {% block title %} • {% block content %} 🔹 Child Templates • Use {% extends "base.html" %} • Fill content inside blocks 💡 Concept: • Parent → structure • Child → content 🔸 Navbar Creation • Navbar is created inside base.html • Appears automatically in all pages 🔹 Key Points: • No need to repeat navbar in every file • Improves code reusability 🔸 URL Naming (Important) • Each URL is given a name in urls.py • Used for linking pages dynamically 🔹 Why use it? • Avoid hardcoding links • Easier to manage routes 🔸 Navigation using Django URL Tag • Instead of writing direct paths, use: 👉 {% url 'name' %} 🔹 Key Points: • Links pages using URL names • Makes navigation dynamic and clean 🔸 Complete Flow User clicks navbar link URL name is matched View function is called Template is rendered Data is displayed ✨ Today you learned: • How to use loops in Django templates • How to handle multiple HTML pages • Template inheritance (base + child structure) • How to build reusable layouts (navbar) • Dynamic navigation using URL names This is a major step toward building structured and professional Django applications 🚀 #Django #Python #WebDevelopment #FullStack #Day85 #Templates #Frontend #BackendDevelopment #CodingJourney
To view or add a comment, sign in
-
Django vs FastAPI vs REST 1. Django ● Full-stack framework with built-in ORM, authentication, and admin ● Best suited for monolithic applications and CRUD-heavy systems ● Ideal when you need rapid development with standard patterns ● Strong choice for internal tools and admin dashboards 2. FastAPI ● Lightweight, high-performance framework with async support ● Best suited for microservices and low-latency APIs ● Ideal for real-time systems and ML/AI model serving ● Gives flexibility to choose your own components (ORM, auth, etc.) 3. REST API ● Architectural style, not a framework ● Defines how APIs should be structured using HTTP methods ● Can be implemented using Django (DRF) or FastAPI ■When to Use ● Use Django when building a complete product with built-in features ● Use FastAPI when performance and scalability are critical ● Use REST principles to design clean and standardized APIs Summary ● Django = Speed of development + batteries included ● FastAPI = Performance + flexibility ● REST = Design standard for APIs Choose based on system requirements, not trends.
To view or add a comment, sign in
-
-
I used Django REST Framework for 5 years. Then I discovered these hidden features. I felt like I had been using a Ferrari in first gear the whole time. 😅 Here are 5 DRF secrets most developers never find 👇 --- 🔐 Secret 1 — SerializerMethodField Most developers hardcode data in serializers. But SerializerMethodField lets you add ANY custom computed field dynamically. Example: Instead of storing full_name in the database — compute it on the fly from first_name + last_name. class UserSerializer(serializers.ModelSerializer): full_name = serializers.SerializerMethodField() def get_full_name(self, obj): return f"{obj.first_name} {obj.last_name}" No extra DB column. No migration. Just clean data. ✅ --- 🚦 Secret 2 — Built-in API Throttling Most developers build custom rate limiting from scratch. DRF already has it built in — and almost nobody uses it. 3 types: → AnonRateThrottle — for unauthenticated users → UserRateThrottle — for authenticated users → ScopedRateThrottle — per specific endpoint REST_FRAMEWORK = { 'DEFAULT_THROTTLE_RATES': { 'anon': '100/day', 'user': '1000/day' } } One setting. Full rate limiting. No extra code. 🔥 --- 📄 Secret 3 — 3 Types of Pagination (Nobody Uses Them All) Most developers only know PageNumberPagination. But DRF has 3: → PageNumberPagination — classic page=1, page=2 → LimitOffsetPagination — ?limit=10&offset=20 — perfect for infinite scroll → CursorPagination — most secure, uses encrypted cursor — perfect for real-time feeds I switched one client's API from PageNumber to Cursor — and their feed felt 10x smoother instantly. 🚀 --- 🎯 Secret 4 — @action Decorator on ViewSets Most developers create separate APIView for every custom endpoint. Messy. Repetitive. Unnecessary. @action lets you add custom endpoints directly inside your ViewSet. class UserViewSet(viewsets.ModelViewSet): @action(detail=True, methods=['post']) def send_welcome_email(self, request, pk=None): user = self.get_object() # send email logic return Response({'status': 'email sent'}) URL: /users/{id}/send_welcome_email/ Clean. Organized. Professional. ✅ --- ⚡ Secret 5 — select_related inside get_queryset Most developers write their queries in the serializer. The result? N+1 queries destroying your API performance. The fix? Override get_queryset in your ViewSet: def get_queryset(self): return Order.objects.select_related( 'user', 'product' ).prefetch_related('items') One change. Query count drops from 47 to 2. ⚡ This is exactly how I reduced a client's API response time from 8 seconds to 800ms. --- These 5 features exist in every DRF project. Most developers never find them. The ones who do — write cleaner code, build faster APIs, and deliver better products. --- Which one did you already know? #Django #DjangoRestFramework #Python #BackendDevelopment #WebDevelopment #FullStackDeveloper #API #SoftwareEngineering #OpenToWork #RemoteWork #ProgrammingTips
To view or add a comment, sign in
-
-
Five things I learned building a Claude Code plugin. Each one is a decision file the plugin captured while I was building it. Link in comments. (When I say "I wrote" below, I mean Claude wrote most of it while I supervised and said "no, not like that." Claude Code builds Claude Code plugins now - fun times.) 1. Markdown files are the truth. Everything else is a cache. Decisions are .md files in .claude/decisions/, plus a auto-generated list at claude/rules/decisions.md that loads at session start. A SQLite search index sits alongside and rebuilds from markdown on demand. Humans and agents both read markdown natively. No parsing layer in between. Karpathy's LLM knowledge bases post took this mainstream. The decision file here predates it, and Claude Code's memory uses the same principle. Not a trend - just what works. 2. No external libraries - just Python's standard library Just what comes with Python. No pip install anything. Took more work - custom YAML parser, FTS5 queries by hand. (Python stdlib got TOML but still no YAML!) - but the plugin can never break someone's Python environment. 3. A tiny bash layer so hooks stay fast Claude Code runs your plugin on every tool use. Python takes ~100ms to start up, so 50 tool calls adds 5 seconds of lag per session. A bash script catches events that don't need Python. Latency stays under 10ms. The first version ran Python on everything - my own plugin annoyed me. 4. A strict order for when policies fire The plugin runs a handful of policies on every hook - detecting decisions, injecting context, nudging. They fire independently but their outputs merge. Without a firing order, weird bugs emerge. A nudge fires before its context. A validation runs after the file is already written. Now there's a fixed order: block, lifecycle, context, nudges. Even if a policy says "reject", the result gets forced to "allow" - nudge-don't-block locked in at the architecture level. A policy can misfire, but none can stop Claude. 5. Skill, hooks, CLI - each does one job Claude Code plugins have three places for logic: a skill (markdown that tells Claude how to behave), hooks (code that runs on events), and a CLI. My first version stuffed everything into the skill. 200 lines of templates, validation, search logic - trying to be an entire program written in English. Now each layer has one job. The skill says what to do - about 60 lines, nothing more. Hooks enforce correctness. The CLI does the computation. The real reason this matters: LLM work costs tokens and is probabilistic. Local code is free and deterministic. Move what you can down to the CLI. --- Would love to hear from others building Claude Code plugins - or thinking about it. What's working, what's stuck. #ClaudeCode #PluginDevelopment #Python #OpenSource #DevTools
To view or add a comment, sign in
-
I have recently been reading Swizec Teller's new book Scaling Fast and in it he mentions architectural complexity, which reminded me of my desire for a tool that combines database dependencies between Django apps and import dependencies between Django apps. To date, I have used other tools such as graph models from Django extensions, import-linter is the most recent one, and pyreverse from Pylint. They all do bits of the job, but require manual stitching together to get a cohesive graph of everything overlaid in the right way. So I remembered about this, and so over the last couple of days, I've built a new package which combines all of this into a live view which updates as you build your app, a management command and a panel for Debug Toolbar. Why the Django app level, you ask? Primarily, I do find models good, but they can get a little too complicated and a little you get a few too many lines and doing imports at the module level within an app or like separating it all out, again, you lose it becomes there becomes too much noise to signal to really understand the logical relationship between different components in the system. I like to think that Django apps naturally represent logical representations of different parts of a project or a system. A project obviously is too large unless you're dealing with multiple projects, but within a single Django project, it's a good representation to have an app deal with one thing. You can I know you can structure Django projects & apps in many ways. So it'd be interesting to see this tool used on other's project structures that aren't one app for a single logical component. So without further ado, here is Django Dependency Map , which combines output from Django extensions graph_models and grimp, which is used by import-linter to dynamically map the dependencies between your different apps and third-party apps. Initially, it was a management command, which then outputs a HTML file, which exists. I then added that into a live view, and there's an integration into Django debug toolbar. The live map page has the following features: you can hide nodes and kind of see how the dependencies change. force graph & hierarchical graph representation, Detailed information on a single app and its relationships import cycle detection import violations from import-linter Debug toolbar panel Export of the graph to mermaid & dot formats My hope is twofold. One, it might reveal things about your projects that you didn't know about in terms of how fit how interlinked things are. And secondly, I hope it may change the way you build your Django apps. I'm hoping to have it open as another tab and just to watch as I'm building things to make sure out as I'm and maybe as an agent's building things see use it as a sense check of if it's doing things right or as I expect it to in terms of overall architecture rather than at the code level. The pypi package is coming very soon, but you can visit the repo here: https:/
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗕𝗲𝗻𝗲𝗳𝗶𝗍𝘀 𝗢𝗳 𝗖𝗹𝗮𝘀𝘀-𝗕𝗮𝘀𝗲𝗱 𝗩𝗶𝗲𝘄𝘀 You can write views as functions or classes in Django. Class-Based Views (CBVs) are a cleaner alternative to function-based views. Here's how you can write a view using both methods: - Function-based view: def post_list(request): posts = Post.objects.all() return render(request, 'core/post_list.html', {'posts': posts}) - Class-based view: class PostListView(ListView): model = Post template_name = 'core/post_list.html' context_object_name = 'posts' Both views do the same thing. The CBV version is shorter because it handles the queryset fetching and context building automatically. Django provides generic views for common patterns. You can use these views to handle tasks like listing, creating, updating, and deleting objects. CBVs need .as_view() when connecting to a URL. You can also use mixins to add functionality to your views. Now that you understand CBVs, Django REST Framework (DRF) becomes easier to understand. DRF is essentially CBVs built for APIs instead of HTML pages. DRF handles tasks like serializing Python objects to JSON, deserializing and validating incoming JSON, and authentication for APIs. You can use serializers to convert model instances to JSON and validate incoming data. API views work like CBVs, and generic API views cut boilerplate to almost nothing. You can use DRF to build a JSON API from the same Django project that serves HTML pages. Source: https://lnkd.in/gswbYync
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
Nice, keep going