<?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: Mamadou762</title>
    <description>The latest articles on DEV Community by Mamadou762 (@mamadou762).</description>
    <link>https://dev.to/mamadou762</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%2F1420569%2F8632ceed-8f0e-4f22-9ab9-e7157572fd35.png</url>
      <title>DEV Community: Mamadou762</title>
      <link>https://dev.to/mamadou762</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mamadou762"/>
    <language>en</language>
    <item>
      <title>How to effectively use PUT and DELETE HTTP methods in Django Class-Based Views?</title>
      <dc:creator>Mamadou762</dc:creator>
      <pubDate>Fri, 12 Apr 2024 07:57:36 +0000</pubDate>
      <link>https://dev.to/mamadou762/how-to-effectively-use-put-and-delete-http-methods-in-django-class-based-views-ip9</link>
      <guid>https://dev.to/mamadou762/how-to-effectively-use-put-and-delete-http-methods-in-django-class-based-views-ip9</guid>
      <description>&lt;p&gt;I'm setting up a CRUD system with Django, using Class-Based Views. Currently I'm trying to figure out how to handle HTTP PUT and DELETE requests in my application. Despite searching the Django documentation extensively, I'm having trouble finding concrete examples and clear explanations of how to submit these types of queries to a class-based view.&lt;/p&gt;

&lt;p&gt;I created a view class named CategoryView, extending from: django.views.View, in which I implemented the get and post methods successfully. And I want to build my urls like this:   &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;New Category: 127.0.0.1:8000/backendapp/categories/create&lt;/li&gt;
&lt;li&gt;List all Category: 127.0.0.1:8000/backendapp/categories/&lt;/li&gt;
&lt;li&gt;Retrieve only one Category: 127.0.0.1:8000/backendapp/categories/1&lt;/li&gt;
&lt;li&gt;Etc...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, when I try to implement the put and delete methods, I get stuck.&lt;/p&gt;

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

&lt;p&gt;from django.views import View&lt;/p&gt;

&lt;p&gt;class CategoryView(View):&lt;br&gt;
     template_name = 'backendapp/pages/category/categories.html'&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; def get(self, request):
     categories = Category.objects.all()

     context = {
         'categories': categories
     }

     return render(request, self.template_name, context)

 def post(self, request):
     return

 def delete(self, request, pk):
     return

 def put(self, request):
     return
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I read through the Django documentation and found that Class-Based Views support HTTP requests: &lt;code&gt;["get", "post", "put", "patch", "delete", "head ", "options", "trace"]&lt;/code&gt;.&lt;br&gt;
Link: &lt;a href="https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View"&gt;Djando documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Despite this, I can't figure out how to do it.&lt;/p&gt;

&lt;p&gt;So I'm asking for your help to unblock me.&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>http</category>
      <category>crud</category>
    </item>
    <item>
      <title>How to effectively use PUT and DELETE HTTP methods in Django Class-Based Views?</title>
      <dc:creator>Mamadou762</dc:creator>
      <pubDate>Fri, 12 Apr 2024 07:57:36 +0000</pubDate>
      <link>https://dev.to/mamadou762/how-to-effectively-use-put-and-delete-http-methods-in-django-class-based-views-1n6h</link>
      <guid>https://dev.to/mamadou762/how-to-effectively-use-put-and-delete-http-methods-in-django-class-based-views-1n6h</guid>
      <description>&lt;p&gt;I'm setting up a CRUD system with Django, using Class-Based Views. Currently I'm trying to figure out how to handle HTTP PUT and DELETE requests in my application. Despite searching the Django documentation extensively, I'm having trouble finding concrete examples and clear explanations of how to submit these types of queries to a class-based view.&lt;/p&gt;

&lt;p&gt;I created a view class named CategoryView, extending from: django.views.View, in which I implemented the get and post methods successfully. And I want to build my urls like this:   &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;New Category: 127.0.0.1:8000/backendapp/categories/create&lt;/li&gt;
&lt;li&gt;List all Category: 127.0.0.1:8000/backendapp/categories/&lt;/li&gt;
&lt;li&gt;Retrieve only one Category: 127.0.0.1:8000/backendapp/categories/1&lt;/li&gt;
&lt;li&gt;Etc...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, when I try to implement the put and delete methods, I get stuck.&lt;/p&gt;

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

&lt;p&gt;from django.views import View&lt;/p&gt;

&lt;p&gt;class CategoryView(View):&lt;br&gt;
     template_name = 'backendapp/pages/category/categories.html'&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; def get(self, request):
     categories = Category.objects.all()

     context = {
         'categories': categories
     }

     return render(request, self.template_name, context)

 def post(self, request):
     return

 def delete(self, request, pk):
     return

 def put(self, request):
     return
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I read through the Django documentation and found that Class-Based Views support HTTP requests: &lt;code&gt;["get", "post", "put", "patch", "delete", "head ", "options", "trace"]&lt;/code&gt;.&lt;br&gt;
Link: &lt;a href="https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View"&gt;Djando documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Despite this, I can't figure out how to do it.&lt;/p&gt;

&lt;p&gt;So I'm asking for your help to unblock me.&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>http</category>
      <category>crud</category>
    </item>
  </channel>
</rss>
