<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nasser El Idrissi </title>
    <description>The latest articles on DEV Community by Nasser El Idrissi  (@abdenasser).</description>
    <link>https://dev.to/abdenasser</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F693109%2Fb030f36b-1537-406b-8d86-9d4cc33d11be.jpeg</url>
      <title>DEV Community: Nasser El Idrissi </title>
      <link>https://dev.to/abdenasser</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdenasser"/>
    <language>en</language>
    <item>
      <title>NeoHtop: A Cross-Platform Activity Monitor Written in Svelte and Tauri🚀</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Sat, 09 Nov 2024 21:04:31 +0000</pubDate>
      <link>https://dev.to/abdenasser/neohtop-a-cross-platform-activity-monitor-written-in-svelte-and-tauri-1n8d</link>
      <guid>https://dev.to/abdenasser/neohtop-a-cross-platform-activity-monitor-written-in-svelte-and-tauri-1n8d</guid>
      <description>&lt;p&gt;Hey everyone! I’m excited to share with you NeoHtop, a new Cross-Platform Activity Monitor that I built using Rust, Svelte, and Tauri. Inspired by classic tools like Htop, NeoHtop combines modern design with the responsiveness of Svelte for a clean, powerful user experience.&lt;/p&gt;

&lt;p&gt;Key Features:&lt;br&gt;
Modular and Customizable: Tweak it to your needs with various modules for resource monitoring.&lt;/p&gt;

&lt;p&gt;Cross-Platform: Fully compatible with Windows, macOS, and Linux, so you can keep your favorite tool across systems.&lt;/p&gt;

&lt;p&gt;Modern UI: Uses Svelte for a smooth and intuitive interface.&lt;/p&gt;

&lt;p&gt;Performance-Focused: Built with Rust, offering reliability and efficiency without sacrificing speed.&lt;/p&gt;

&lt;p&gt;Themable: VSCode inspired theming system.&lt;/p&gt;

&lt;p&gt;and many more to discover by yourself&lt;/p&gt;

&lt;p&gt;Github &lt;a href="https://github.com/Abdenasser/neohtop" rel="noopener noreferrer"&gt;https://github.com/Abdenasser/neohtop&lt;/a&gt;&lt;br&gt;
Website &lt;a href="https://abdenasser.github.io/neohtop/" rel="noopener noreferrer"&gt;https://abdenasser.github.io/neohtop/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>A fun story about coding</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Wed, 06 Nov 2024 13:32:27 +0000</pubDate>
      <link>https://dev.to/abdenasser/a-fun-story-about-coding-5ebf</link>
      <guid>https://dev.to/abdenasser/a-fun-story-about-coding-5ebf</guid>
      <description>&lt;p&gt;It all started on a lazy Sunday afternoon. You know those days when you’re just scrolling mindlessly through Twitter, and your browser starts acting up? Yeah, one of those. My ARC browser was being particularly dramatic that day, probably throwing a tantrum because I had about 47 tabs open (don’t judge, we all do it - that’s why we switched to ARC in the first place, right?).&lt;/p&gt;

&lt;p&gt;So there I was, desperately trying to figure out why my RAM was disappearing faster than free pizza at a developer meetup. I opened Activity Monitor, but come on - its interface looks like it was designed in the era when people still debated tabs vs spaces. That’s when nostalgia hit me, and I found myself missing the clean, terminal-based beauty of htop from my Linux days.&lt;/p&gt;

&lt;p&gt;“Let me home brew a htop (I don’t have it installed on my mac, like seriously? during my career I used monitoring tools like top, htop, 3 or 4 times and I’m not even kidding, like what the fuck I’d need them for? 🤷‍♂️), then I thought wait is there a decent gui alternative for macOS,” I thought. Big mistake. Or maybe the best mistake ever?&lt;/p&gt;

&lt;p&gt;After browsing through some alternatives that looked like they were designed when dial-up internet was still cool 💾, I had what alcoholics call a “moment of clarity”: “Hey, I’ve been meaning to learn Rust, and everyone’s talking about this Tauri shit… and I don’t want to build the next 1 billion dollar todo list app 🤔”&lt;/p&gt;

&lt;p&gt;“How hard could it be to build a system monitor? It’s just numbers going up and down, right?”&lt;/p&gt;

&lt;p&gt;Oh, sweet summer child.&lt;/p&gt;

&lt;p&gt;First stop: The Rust book. You know, the one everyone says you should read cover to cover before even thinking about writing “Hello, World!” I made it halfway through, just enough to understand ownership and borrowing (which is like learning about relationships in therapy - it’s all about who owns what and who’s just borrowing feelings), and that Traits are basically Rust’s way of doing interfaces like in Go. Then I had my second moment of clarity: “Wait a minute, Rust is a systems language… there’s gotta be a crate for system stuff, right?”&lt;/p&gt;

&lt;p&gt;Turns out, there were like fifty of them. But hey, decision paralysis is just part of the modern developer experience, right?&lt;/p&gt;

&lt;p&gt;Now for the frontend. Tauri is framework-agnostic, which means I could’ve used React or Angular. But let’s be real - shipping your app with React is like bringing an entire orchestra when all you needed was a kazoo. Plus, I’ve got principles, dammit! That’s when I remembered Svelte, that beautiful compiler-first framework that React developers are now trying to copy with their “compiler magic” (How’s that for innovation, Zuck?).&lt;/p&gt;

&lt;p&gt;The first iteration was… functional. Basic Tauri invokes were working (just sprinkle invoke() everywhere like it’s fairy dust ✨), but it looked about as exciting as a terminal running ping. And if we’re making a GUI (and not shipping an entire Chromium instance like some other electron-ic frameworks I could mention - yeah, we’re using native webview because we’re not monsters), it better look good. That’s when the icon adventure began…&lt;/p&gt;

&lt;p&gt;I spent THREE DAYS just trying to figure out how to get proper icons for processes. THREE. DAYS. The solution? A weird combination of SimpleIcons and some regex magic that I’m pretty sure summoned a minor demon in the process.&lt;/p&gt;

&lt;p&gt;But then something magical happened. The UI started coming together, and it actually looked… good? The dark mode wasn’t burning my retinas (looking at you, htop), and the performance metrics were dancing across the screen like they were at a disco.&lt;/p&gt;

&lt;p&gt;You see, I’d been spending way too much time on Reddit looking at those fancy neofetch screenshots that cool kids keep sharing (you know the ones - where their terminal looks cooler than most people’s entire desktop setup). That’s actually what inspired the name “NeoHtop” - a little nod to neofetch and its aesthetic-obsessed community. But why stop at just pretty colors?&lt;/p&gt;

&lt;p&gt;That’s when it hit me - if developers can spend hours customizing their code editors 🎨, why not let them do the same with their system monitor? Making the app themable wasn’t just about looking pretty; it was about giving users that same dopamine hit they get from perfectly customizing their VS Code setup. (And let’s be honest, we all know at least one developer who spends more time theming their editor than actually coding.)&lt;/p&gt;

&lt;p&gt;I threw in some fancy animations, because why not? If we’re monitoring system resources, might as well do it with style. The irony of potentially using more resources to monitor resources was not lost on me.&lt;/p&gt;

&lt;p&gt;And I kept going! Because apparently, I can’t leave well enough alone. I added search functionality (because scrolling is so 2023), filtering by status (for those who really need to know which processes are “sleeping” - you know, like we all wish we were), and even pagination (why would an activity monitor need pagination, you ask? Well… I asked myself the same question, but couldn’t come up with a good reason why NOT to add it 🤷‍♂️).&lt;/p&gt;

&lt;p&gt;I even wrote a few posts about it on Reddit and dev.to, with a little help from ChatGPT (because who has time to write coherent sentences when you’re busy adding unnecessary features? 🤪). That backfired a bit when some keyboard warrior on dev.to decided to call me out for using ChatGPT - which I hadn’t even denied! But karma works in mysterious ways: the post got so popular that dev.to blessed me with some admin superpowers. Let’s just say certain negative comments found themselves taking a journey to the bottom of the thread. Hey, with great power comes great… ability to reorganize comments? 😈&lt;/p&gt;

&lt;p&gt;Then came the real “oh shit” moment. Thanks to Marouane (my friend and coworker who I’ll never forgive for this), I decided to post it on GitHub, thinking “maybe a few people will find it useful.” You know, the usual: mom, my puppy, and that one friend who stars everything I post.&lt;/p&gt;

&lt;p&gt;But apparently, I wasn’t the only one who thought Activity Monitor needed a glow-up ✨. Within 24 hours, the stars started rolling in. By day six, we hit 1,000 stars 🌟. My notifications were going crazy, and my impostor syndrome was having the time of its life…and started asking myself what is this madness? what am I doing with my life? Am I going to spend the rest of my life replying to peoples issues on GitHub? I mean, I love open source and all, but I had a life too! and a little kid to take care of! and a wife! and a house! and a mortgage! and a cat! and a dog! and a life! what the kind of shit I stepped into now?.. anyways it’s just a little tool right? not like I’m building the next big thing here…a bit of a stretch, but ok.&lt;/p&gt;

&lt;p&gt;The best part? People actually started using it! Real people! And they were sending PRs and opening issues for suggestions.. stupid ones but also lot of good ones too!&lt;/p&gt;

&lt;p&gt;And here we are now, with a full-featured system monitor that started because Arc was being a memory hog for the first time in months. The moral of the story? Sometimes the best projects come from the most mundane problems. it not really about the project, it’s about the process.. the experience.. the journey.. the lessons.. the people.. the laughs.. the memories.. what the fuck am I doing with my life? what memories? what laughs? what lessons? what journey? what process? what project?… just kidding, it’s about the learning by doing.&lt;/p&gt;

&lt;p&gt;P.S. If you’re wondering about the version history (spoiler: there were a lot of “fix typo” commits hidden in the commit history under other commits messages like “updating dependencies”, “updating icons”, “updating download links”, etc.):&lt;/p&gt;

&lt;p&gt;Yeah, we’re at 1.0.5 now. Each version bump represents at least one “it works on my machine” moment and several sips of coffee.&lt;/p&gt;

&lt;p&gt;Remember kids: Sometimes the best way to learn new tech is to build something you need, even if you end up way over your head. Just make sure to add some nice animations – they hide the pain of debugging memory leaks. And if you’re going to name your project after something, might as well pick something that the cool kids are already hyping up on Reddit! 😅&lt;/p&gt;

&lt;p&gt;P.S.S. If you’re wondering how I’m writing this post, remeber I’m not using ChatGPT for this one.. with great power comes great responsibility.&lt;/p&gt;

&lt;p&gt;Give NeoHtop a try, it’s free and open source: &lt;a href="https://github.com/Abdenasser/neohtop" rel="noopener noreferrer"&gt;NeoHtop on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I love Rust/Tauri &amp; Svelte</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Fri, 01 Nov 2024 13:41:35 +0000</pubDate>
      <link>https://dev.to/abdenasser/i-love-rusttauri-svelte-5bae</link>
      <guid>https://dev.to/abdenasser/i-love-rusttauri-svelte-5bae</guid>
      <description>&lt;p&gt;Hey DEV community! 👋 I recently built a native task manager for macOS that brings the htop experience to the desktop. After sharing it on &lt;a href="https://www.reddit.com/r/rust/comments/1gfzrdx/my_first_attempt_at_tauri/?utm_source=share&amp;amp;utm_medium=web3x&amp;amp;utm_name=web3xcss&amp;amp;utm_term=1&amp;amp;utm_content=share_button" rel="noopener noreferrer"&gt;Reddit&lt;/a&gt; and getting amazing feedback, I wanted to share what I learned here as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Project: NeoHtop
&lt;/h2&gt;

&lt;p&gt;NeoHtop is a modern, native process monitoring tool that combines the power of terminal-based system monitors with a clean, desktop-native UI. Check it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔗 &lt;a href="https://abdenasser.github.io/neohtop/" rel="noopener noreferrer"&gt;Website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;a href="https://github.com/Abdenasser/neohtop" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;p&gt;🚀 Real-time process monitoring&lt;br&gt;
💻 CPU and Memory usage tracking&lt;br&gt;
🎨 Beautiful, modern UI with dark/light themes&lt;br&gt;
🔍 Process search and filtering&lt;br&gt;
📌 Pin important processes&lt;br&gt;
🛠 Process management (kill processes)&lt;br&gt;
🎯 Sort by any column&lt;br&gt;
🔄 Auto-refresh system stats&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;and more...&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tech Stack &amp;amp; Architecture
&lt;/h2&gt;

&lt;p&gt;For this project, I went with a Rust and Tauri backend paired with a Svelte frontend. The backend uses the fantastic &lt;code&gt;sysinfo&lt;/code&gt; crate to collect system metrics efficiently. What I love about this combination is how Rust handles all the heavy lifting - from process monitoring to CPU/Memory calculations - while Tauri seamlessly bridges the gap between native capabilities and web technologies.&lt;/p&gt;

&lt;p&gt;On the frontend side, Svelte has been a joy to work with. Its reactive nature made it perfect for building the UI components that need constant updates. I particularly enjoyed implementing the themes switcher and integrating SimpleIcons to give each process a distinctive visual identity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Challenges &amp;amp; Solutions
&lt;/h2&gt;

&lt;p&gt;Building NeoHtop came with its fair share of interesting challenges. Performance was the biggest one - keeping everything smooth while updating multiple processes in real-time isn't trivial. The solution came from leveraging Rust's efficiency for heavy computations and establishing a fast IPC bridge to the frontend.&lt;/p&gt;

&lt;p&gt;The most... interesting part? Dealing with Apple's certification process 😅. Between code signing, notarization, and configuring entitlements, it felt like navigating a maze. But hey, it was a great learning experience!&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;This project really opened my eyes to the power of Rust and Tauri for desktop applications. The developer experience was fantastic, and the performance speaks for itself. Svelte's simplicity made frontend development a breeze, though I learned to be extra careful when dealing with native APIs, especially on macOS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;I'm excited about the future of NeoHtop! I'm planning to add Linux support, implement more process management features, and include detailed system metrics. Network usage monitoring is high on the priority list too. I'm also planning to write a detailed technical article diving deep into the implementation details, especially around performance optimization and the IPC bridge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Join the Journey!
&lt;/h2&gt;

&lt;p&gt;I'd love for you to try out NeoHtop and share your thoughts. Have you built desktop apps with Tauri? How was your experience with Rust in desktop development? Let's chat in the comments!&lt;/p&gt;

&lt;p&gt;Stay tuned for my upcoming technical deep-dive article where I'll break down the architecture and share some code snippets! 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Out!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;📥 &lt;a href="https://abdenasser.github.io/neohtop/" rel="noopener noreferrer"&gt;Download NeoHtop&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;⭐ &lt;a href="https://github.com/Abdenasser/neohtop" rel="noopener noreferrer"&gt;Star on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tauri</category>
      <category>rust</category>
      <category>svelte</category>
      <category>opensource</category>
    </item>
    <item>
      <title>10x django developer</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Fri, 03 Sep 2021 18:57:57 +0000</pubDate>
      <link>https://dev.to/abdenasser/10x-django-developer-42p7</link>
      <guid>https://dev.to/abdenasser/10x-django-developer-42p7</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/YGjNFdccr0Q"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;if you are wondering what this is using here is the package and don't forget to support it by dropping a star ⭐&lt;/p&gt;

&lt;p&gt;github repo: &lt;a href="https://github.com/Abdenasser/dr_scaffold" rel="noopener noreferrer"&gt;dr_scaffold&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;tutorial: &lt;a href="https://dev.to/abdenasser/scaffold-django-apis-like-a-champion-1595"&gt;make a full api in seconds&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>tooling</category>
    </item>
    <item>
      <title>My personal django rest framework serializer notes</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Thu, 02 Sep 2021 09:46:03 +0000</pubDate>
      <link>https://dev.to/abdenasser/my-personal-django-rest-framework-serializer-notes-2i22</link>
      <guid>https://dev.to/abdenasser/my-personal-django-rest-framework-serializer-notes-2i22</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcrbbrquqluuxpexxxodb.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcrbbrquqluuxpexxxodb.jpeg" alt="My personal django rest framework serializer notes" width="638" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before today it was only me and God who can read my hand writing, but today it is only God who can... today I got stuck reading one of my DRF drafts about &lt;code&gt;serializers&lt;/code&gt; and decided that it's that time of the year again where I start thinking that I should have a blog where I can save my notes -then forget about it again-, but as I already got a &lt;a href="//abdenasser.com"&gt;blog&lt;/a&gt; I said why not 🤔 ? ... let's create a digital copy of my drf serializer notes, maybe someone will find it useful.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;save time creating django apis with &lt;a href="https://github.com/Abdenasser/dr_scaffold" rel="noopener noreferrer"&gt;this cool django package&lt;/a&gt;, and support the repository by dropping a star ⭐&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Let's define an Index or a table of content that we can use as reference in the future.&lt;/p&gt;
&lt;h2&gt;
  
  
  Table of content
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 - Fields
  --------------------------
  - Serializer Method Field
  - Read Only Field
  - Custom Field Validation
  - Using Multiple Serializers
  --------------------------
2 - Data
  --------------------------
  - Custom Data Validation
  - Custom Output with `to_representation`()
  - Custom Input with `to_internal_value`().
  - Pass additional data directly to `save()`
  --------------------------
3 - Keywords
  --------------------------
  - The `source` Keyword
  - The `context` Keyword
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  1- Fields
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Serializer Method Field
&lt;/h3&gt;

&lt;p&gt;This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SerializerMethodField&lt;/code&gt; gets its data by calling &lt;code&gt;get_&amp;lt;field_name&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;days_since_joined&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SerializerMethodField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;
        &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__all__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_days_since_joined&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date_joined&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;days&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read Only Field
&lt;/h3&gt;

&lt;p&gt;Read-only fields are included in the API output, but should not be included in the input during create or update operations. Any &lt;code&gt;read_only&lt;/code&gt; fields that are incorrectly included in the serializer input will be ignored.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AccountSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Serializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IntegerField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;read_only&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Custom Field Validation
&lt;/h3&gt;

&lt;p&gt;Validation in Django REST framework serializers is handled a little differently to how validation works in Django's ModelForm class.&lt;/p&gt;

&lt;p&gt;With ModelForm the validation is performed partially on the form, and partially on the model instance. With REST framework the validation is performed entirely on the serializer class.&lt;/p&gt;

&lt;p&gt;Let's take an example where we want to only allow students that have age between 12 and 18:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StudentSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate_age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Age has to be between 12 and 18.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Multiple Serializers
&lt;/h3&gt;

&lt;p&gt;You can override the &lt;code&gt;get_serializer_class()&lt;/code&gt; of your &lt;code&gt;ViewSet&lt;/code&gt; when for example you want to use a different Serializer in your create and update actions like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyViewSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;viewsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelViewSet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;queryset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MyModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_serializer_class&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;create&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;update&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;WriteSerializer&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ReadSerializer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h2&gt;
  
  
  2- Data
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Custom Data Validation
&lt;/h3&gt;

&lt;p&gt;Besides &lt;strong&gt;Custom Field Validation&lt;/strong&gt;, there are two additional ways we can use to validate our data, when for example we need to compare some of our fields between each other the best way to do that is on the object level.&lt;/p&gt;

&lt;p&gt;example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;discount_amount&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;total_amount&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;discount cannot be bigger than the total amount&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another good way to do validation is when a validation logic is repeated multiple times in some serializers, you can then extract it to a function, example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_valid_age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;age cannot be lower than 12.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;age cannot be higher than 18&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can pass it like this in the other serializers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnotherSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IntegerField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;validators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;is_valid_age&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Custom Output with &lt;code&gt;to_representation()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;When you want to customize the output right before it is sent use &lt;code&gt;to_representation()&lt;/code&gt;, imagine you have an output like the following after serialization is completed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"abdenasser"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"bio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hey ... you already know!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"followed_by"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you want to add a total followers count to it... you can simply do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ResourceSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_representation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;representation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;to_representation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;representation&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;followers&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;followed_by&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;representation&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you'll get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"abdenasser"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"bio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hey ... you already know!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"followed_by"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"followers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Custom Input with &lt;code&gt;to_internal_value()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Let's say that your API is expecting some input from a 3rd party service and you are only interested in a chunk of that input, you can use &lt;code&gt;to_internal_value()&lt;/code&gt; as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SomeSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_internal_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;useful_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;useful&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;to_internal_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;useful_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pass additional data directly to save()
&lt;/h3&gt;

&lt;p&gt;Calling &lt;code&gt;.save()&lt;/code&gt; will either create a new instance, or update an existing instance, depending on if an existing instance was passed when instantiating the serializer class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .save() will create a new instance.
&lt;/span&gt;&lt;span class="n"&gt;serializer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CommentSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# .save() will update the existing `comment` instance.
&lt;/span&gt;&lt;span class="n"&gt;serializer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CommentSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h2&gt;
  
  
  3- Keywords
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The source Keyword
&lt;/h3&gt;

&lt;p&gt;In essence, you can use &lt;code&gt;source&lt;/code&gt; in a field like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;field_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SomeFieldType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;prop&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;prop&lt;/code&gt; could be a call for a function that return some value, or a property that exists in a related model like &lt;code&gt;...(source='author.bio')&lt;/code&gt; or even a serializer field that you want to rename in output.&lt;/p&gt;

&lt;p&gt;You can also attach the whole object with &lt;code&gt;source='*'&lt;/code&gt; if you need.&lt;/p&gt;

&lt;h3&gt;
  
  
  The context Keyword
&lt;/h3&gt;

&lt;p&gt;You can provide arbitrary additional context by passing a context argument when instantiating a serializer. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;serializer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ResourceSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;value&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The context dictionary can then be used within any serializer field logic, such as a custom .to_representation() method, by accessing the self.context attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_representation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;representation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;to_representation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;representation&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;representation&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h2&gt;
  
  
  Final word:
&lt;/h2&gt;

&lt;p&gt;Django Rest Framework has a very good documentation which you can find and read &lt;a href="https://www.django-rest-framework.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;, try to spend some time on it and use it as a fall back any time you feel that things started getting complicated in your serializers, also bare in mind that while you are using serializers you are most of the time using, overriding or extending the base serializer functionalities so go check it out and take a look at it &lt;a href="https://github.com/encode/django-rest-framework/blob/master/rest_framework/serializers.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>discuss</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Scaffold django apis like a champion</title>
      <dc:creator>Nasser El Idrissi </dc:creator>
      <pubDate>Wed, 25 Aug 2021 10:58:42 +0000</pubDate>
      <link>https://dev.to/abdenasser/scaffold-django-apis-like-a-champion-1595</link>
      <guid>https://dev.to/abdenasser/scaffold-django-apis-like-a-champion-1595</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx82o9wdivo2tcxfxkr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx82o9wdivo2tcxfxkr0.png" alt="scaffold django api application with command line" width="800" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey ✋ my name is Abdenasser I'm the creator of this little django scaffold generator &lt;a href="https://github.com/Abdenasser/dr_scaffold" rel="noopener noreferrer"&gt;https://github.com/Abdenasser/dr_scaffold&lt;/a&gt; and today I'm gonna show you how to use it to create ready to use and fully functional REST apis with django only using the command line, let's get started.&lt;/p&gt;

&lt;p&gt;Setting a django environement is outside of the scope of this article, I'm sure there's a lot of guides and tutorials on how to do that all over internet you can follow one of them and get back, we'll be waiting just right here!&lt;/p&gt;

&lt;p&gt;In a nutshell here is the tasks we gonna do through this article:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a django project&lt;/li&gt;
&lt;li&gt;Setup djangorestframework and dr_scaffold&lt;/li&gt;
&lt;li&gt;Scaffold a blog api with Articles and Authors&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enjoying 🎉&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Create a django project:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Le't create a django project using this django-admin command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;django-admin startproject myApi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;this command does the same as &lt;code&gt;python manage.py startproject myApi&lt;/code&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Let's then cd to our newly created django project &lt;code&gt;cd myApi&lt;/code&gt; and create a virtualenv with:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; virtualenv &lt;span class="nb"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally let's activate our virtual env with:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;source env&lt;/span&gt;/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Setup djangorestframework and dr_scaffold:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Let's install django rest framework and dr_scaffold packages using pip like the following:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;djangorestframework
&lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;dr-scaffold
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Next let's add these packages to our project &lt;code&gt;INSTALLED_APPS&lt;/code&gt; inside &lt;code&gt;myApi/settings.py&lt;/code&gt; like this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rest_framework&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dr_scaffold&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then let's add our core and api folders settings to &lt;code&gt;myApi/settings.py&lt;/code&gt;, (for the simplicity of the tutorial we'll leave them empty):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;CORE_FOLDER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;  &lt;span class="c1"&gt;# you can leave them empty
&lt;/span&gt;&lt;span class="n"&gt;API_FOLDER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;   &lt;span class="c1"&gt;# or set them to be the same
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Scaffold a blog api with Articles and Authors
&lt;/h2&gt;

&lt;p&gt;Our blog api will be composed of two main resources an Article and a Author.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's scaffold our Author first:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py dr_scaffold blog Author name:charfield

🎉 Your RESTful Author api resource is ready 🎉
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;this command will generate a blog folder with &lt;code&gt;models.py&lt;/code&gt;&lt;br&gt;
 &lt;code&gt;admin.py&lt;/code&gt; &lt;code&gt;views.py&lt;/code&gt; &lt;code&gt;serializers.py&lt;/code&gt; &lt;code&gt;urls.py&lt;/code&gt; all populated with appropriate code that your REST api needs for Author resource&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Lets also generate the Article resource:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py dr_scaffold blog Post body:textfield author:foreignkey:Author

🎉 Your RESTful Post api resource is ready 🎉
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;this command will do the same thing but also will add a relation to our Author resource through a &lt;code&gt;foreignkey&lt;/code&gt; field.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;In order to generate the database tables let's add blog to our &lt;code&gt;INSTALLED_APPS&lt;/code&gt; inside &lt;code&gt;myApi/settings.py&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rest_framework&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dr_scaffold&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;blog&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then let's run these commands to generate our migrations and migrate the database:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py makemigrations
&lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally add our blog to our project's &lt;code&gt;urlpatterns&lt;/code&gt; inside &lt;code&gt;myApi/urls.py&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...,&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blog/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blog.urls&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Don't forget to import include in your project's &lt;code&gt;urls.py&lt;/code&gt; like so :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.conf.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;include&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Your &lt;code&gt;urls.py&lt;/code&gt; should look something like this in the end:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.conf.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;include&lt;/span&gt; &lt;span class="c1"&gt;#our added import
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;

&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;admin/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blog/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blog.urls&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="c1"&gt;#our added bol path
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now run &lt;code&gt;python manage.py runserver&lt;/code&gt; and head over to &lt;code&gt;http://127.0.0.1:8000/blog/&lt;/code&gt; to see your fully created REST blog API.. and also you can generate a super user with &lt;code&gt;python manage.py createsuperuser&lt;/code&gt; then head over to &lt;code&gt;http://127.0.0.1:8000/admin&lt;/code&gt; to check the admin panel.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't forget to star the &lt;a href="https://github.com/Abdenasser/dr_scaffold" rel="noopener noreferrer"&gt;repo&lt;/a&gt; on github If you like it.. Enjoy 🎉 !&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
