Re: How to effectively use PUT and DELETE HTTP methods in Django Class-Based Views?

2024-04-12 Thread Luis Zárate
Also a recomendation, see that `dispatch` method call the view as

handler(request, *args, **kwargs)

So maybe is a good idea do something like:

class MyView(view):
 def put(self, request, *args, **kwargs):
...


Regards,

El vie, 12 abr 2024 a las 16:13, Luis Zárate ()
escribió:

> See
> https://docs.djangoproject.com/en/5.0/topics/class-based-views/#supporting-other-http-methods
> Also on view you have a variable called, where you can limit the available
> methods.
>
> http_method_names
>
>
> El vie, 12 abr 2024 a las 7:20, Mamadou Alpha Bah (<
> mamadoualphabah...@gmail.com>) escribió:
>
>> 
>>
>> 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.
>>
>> 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:
>>
>>1. New Category: 127.0.0.1:8000/backendapp/categories/create
>>2. List all Category: 127.0.0.1:8000/backendapp/categories/
>>3. Retrieve only one Category: 127.0.0.1:8000/backendapp/categories/1
>>4. Etc...
>>
>> However, when I try to implement the put and delete methods, I get stuck.
>>
>> For example :
>> from django.views import View
>>
>> class CategoryView(View):
>>  template_name = 'backendapp/pages/category/categories.html'
>>
>>  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
>>
>> I read through the Django documentation and found that Class-Based Views
>> support HTTP requests: ["get", "post", "put", "patch", "delete", "head ",
>> "options", "trace"].
>>
>> link:
>> https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View
>> 
>>
>> Despite this, I can't figure out how to do it.
>>
>> So I'm asking for your help to unblock me.
>>
>> I looked at the Django documentation and searched online for examples and
>> tutorials on handling HTTP requests in class-based views. I also tried
>> experimenting with adding the put and delete methods to my CategoryView
>> view class, but without success. I expected to find resources that clearly
>> explain how to integrate these queries into my Django application, as well
>> as practical examples demonstrating their use. However, I haven't found a
>> working solution and am now seeking help from the community to overcome
>> this difficulty.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b1ecd4a7-5946-4da5-80ae-5923b6648a70n%40googlegroups.com
>> 
>> .
>>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNQtHhV3TPMtB4qLyipdjcnZBZA8_mwf-1_j2F%2B_sER5g%40mail.gmail.com.


Re: How to effectively use PUT and DELETE HTTP methods in Django Class-Based Views?

2024-04-12 Thread Luis Zárate
See
https://docs.djangoproject.com/en/5.0/topics/class-based-views/#supporting-other-http-methods
Also on view you have a variable called, where you can limit the available
methods.

http_method_names


El vie, 12 abr 2024 a las 7:20, Mamadou Alpha Bah (<
mamadoualphabah...@gmail.com>) escribió:

> 
>
> 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.
>
> 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:
>
>1. New Category: 127.0.0.1:8000/backendapp/categories/create
>2. List all Category: 127.0.0.1:8000/backendapp/categories/
>3. Retrieve only one Category: 127.0.0.1:8000/backendapp/categories/1
>4. Etc...
>
> However, when I try to implement the put and delete methods, I get stuck.
>
> For example :
> from django.views import View
>
> class CategoryView(View):
>  template_name = 'backendapp/pages/category/categories.html'
>
>  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
>
> I read through the Django documentation and found that Class-Based Views
> support HTTP requests: ["get", "post", "put", "patch", "delete", "head ",
> "options", "trace"].
>
> link:
> https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View
> 
>
> Despite this, I can't figure out how to do it.
>
> So I'm asking for your help to unblock me.
>
> I looked at the Django documentation and searched online for examples and
> tutorials on handling HTTP requests in class-based views. I also tried
> experimenting with adding the put and delete methods to my CategoryView
> view class, but without success. I expected to find resources that clearly
> explain how to integrate these queries into my Django application, as well
> as practical examples demonstrating their use. However, I haven't found a
> working solution and am now seeking help from the community to overcome
> this difficulty.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1ecd4a7-5946-4da5-80ae-5923b6648a70n%40googlegroups.com
> 
> .
>


-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNsQdYWD4W_Mfr%3DMfdP-DrbYeWf0qAgWDEN6TDbVOpR7A%40mail.gmail.com.


Re: DRF Trailing Slah

2024-04-12 Thread Luis Zárate
Check your URL.py and append the slash, also take a look of
https://docs.djangoproject.com/en/5.0/ref/settings/#append-slash


El vie, 12 abr 2024 a las 15:40, MISHEL HANNA ()
escribió:

> Hello
> i have endpoint when add / to the end of it i can not send request it
> return this
> Not Found: /api/v1/properties/user/
> [12/Apr/2024 20:19:03] "GET /api/v1/properties/user/ HTTP/1.1" 404 23
>
> but when remove / from the end of it return success
> [12/Apr/2024 20:19:09] "GET /api/v1/properties/user HTTP/1.1" 200 635
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d5b533b0-e482-4db5-8a4d-ce925aefcbf4n%40googlegroups.com
> 
> .
>


-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNc9sNk_6qBoF9X7wMbEYtoLmj_Qo-9mXdHyHNSAkTWVQ%40mail.gmail.com.


DRF Trailing Slah

2024-04-12 Thread MISHEL HANNA
Hello
i have endpoint when add / to the end of it i can not send request it 
return this 
Not Found: /api/v1/properties/user/
[12/Apr/2024 20:19:03] "GET /api/v1/properties/user/ HTTP/1.1" 404 23

but when remove / from the end of it return success
[12/Apr/2024 20:19:09] "GET /api/v1/properties/user HTTP/1.1" 200 635


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d5b533b0-e482-4db5-8a4d-ce925aefcbf4n%40googlegroups.com.


How to effectively use PUT and DELETE HTTP methods in Django Class-Based Views?

2024-04-12 Thread Mamadou Alpha Bah
 

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.

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:

   1. New Category: 127.0.0.1:8000/backendapp/categories/create 
   2. List all Category: 127.0.0.1:8000/backendapp/categories/ 
   3. Retrieve only one Category: 127.0.0.1:8000/backendapp/categories/1 
   4. Etc... 

However, when I try to implement the put and delete methods, I get stuck.

For example :
from django.views import View 

class CategoryView(View):
 template_name = 'backendapp/pages/category/categories.html'
 
 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

I read through the Django documentation and found that Class-Based Views 
support HTTP requests: ["get", "post", "put", "patch", "delete", "head ", 
"options", "trace"].

link: 
https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View
 


Despite this, I can't figure out how to do it.

So I'm asking for your help to unblock me.

I looked at the Django documentation and searched online for examples and 
tutorials on handling HTTP requests in class-based views. I also tried 
experimenting with adding the put and delete methods to my CategoryView 
view class, but without success. I expected to find resources that clearly 
explain how to integrate these queries into my Django application, as well 
as practical examples demonstrating their use. However, I haven't found a 
working solution and am now seeking help from the community to overcome 
this difficulty.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1ecd4a7-5946-4da5-80ae-5923b6648a70n%40googlegroups.com.


Is the collect static of ManifestStaticFilesStorage buggy?

2024-04-12 Thread run_the_race
Hi All,

When collecting the *wc-take-message.min.js* file, it fails to find the 
file *x-field.min.css* that is in the correct place.

This is my manifest storage that enables hashing JS modules imports:




*from django.contrib.staticfiles.storage import 
ManifestStaticFilesStorage,class 
LcManifestStaticFilesStorage(ManifestStaticFilesStorage):
support_js_module_import_aggregation = True*

However  when running collect static  it fails:

Heres a snippet from `*comms/wcapp/wc-take-message.min.js*`:
*import w from"/static/skin/skin/x-field.min.css";import u 
from"/static/common/skin/*

And heres the error during collect static:

Post-processing 'comms/wcapp/wc-take-message.min.js' failed!

Traceback (most recent call last):
  File "/home/michael/project/src/manage.py", line 57, in 
run()
  File "/home/michael/project/src/manage.py", line 49, in run
execute_from_command_line(sys.argv)
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/__init__.py",
 
line 442, in execute_from_command_line
utility.execute()
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/__init__.py",
 
line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/base.py",
 
line 413, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/base.py",
 
line 459, in execute
output = self.handle(*args, **options)
 ^
  File 
"/home/michael/project/src/core/app/base/management/commands/deploy.py", 
line 84, in handle
call_command('collectstatic', '--noinput', '--clear', '--verbosity', 
'0')
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/__init__.py",
 
line 194, in call_command
return command.execute(*args, **defaults)
   ^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/core/management/base.py",
 
line 459, in execute
output = self.handle(*args, **options)
 ^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
 
line 209, in handle
collected = self.collect()
^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
 
line 154, in collect
raise processed
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py",
 
line 375, in _post_process
content = pattern.sub(converter, content)
  ^^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py",
 
line 249, in converter
hashed_url = self._url(
 ^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py",
 
line 182, in _url
hashed_name = hashed_name_func(*args)
  ^^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py",
 
line 425, in _stored_name
cache_name = self.clean_name(self.hashed_name(name))
 ^^
  File 
"/home/michael/.venv/project/lib/python3.11/site-packages/django/contrib/staticfiles/storage.py",
 
line 143, in hashed_name
raise ValueError(
ValueError: The file 'skin/skin/x-field.min.c6fe58e9f403.css' could not be 
found with .


But the file exists in the collect static spot:
:/var/www/example.com/public/static/skin/skin$ ls -la x-field.min.css
-rw-r--r-- 1 michael www-data 6387 Apr 12 08:07 x-field.min.css

Not sure why it does not see the file it's looking for?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1407930a-6286-4670-af77-e3800080a6f7n%40googlegroups.com.