Re: How to intermediate all API request calls

2020-01-28 Thread Alexander Lamas
Hi Gonzalo, Yes, you are right! Sorry for that! And sorry for the late reply. The solution for this problem was as follow: I end up creating my own middleware, and the settings.py was set like this MIDDLEWARE = [ 'app.middlewares.CustomizedMiddleware',] I also created a middlewares.py fi

Re: How to intermediate all API request calls

2019-06-05 Thread Gonzalo Amadio
Hi Alex, It is nice that you share your solutions to. =) So if you ask a question and other people share their solutions with you, you give the same feedback to the community. Thank you! Best regards El lun., 20 may. 2019 a las 18:07, Alexander Lamas (< alexander.g.la...@gmail.com>) escribió:

Re: How to intermediate all API request calls

2019-05-20 Thread Alexander Lamas
Hi guys, Actually I'm using middleware already and handling 403, 404 and 500 errors. But I end up handling it in a different way. Thank you very much for your guys help. Much appreciated! Regards, Alex On Wednesday, May 15, 2019 at 6:09:29 PM UTC+9, Alexander Lamas wrote: > > Hi all, > > Do

Re: How to intermediate all API request calls

2019-05-15 Thread Omkar Deshpande
Well, there are three solutions. 1) As soon as the request enters into view, extract the query param, validate it, and return the response accordingly. 2) Use filter backends in views as described above. 3) In custom middleware. Make sure you maintain proper ordering in settings. Prefer first o

Re: How to intermediate all API request calls

2019-05-15 Thread Alan Crosswell
You can do it with a filter backend . Example from a project downstream of DRF here which goes in settings.

How to intermediate all API request calls

2019-05-15 Thread Alexander Lamas
Hi all, Does anyone know how can I intermediate all API calls to my DRF app before it gets into my views and/or serializers? My point is, I'm passing a parameter in the API URL and if this parameter is invalid I want to return a 404 error to my application and don't let it reaches my views and

Re: How to intermediate all API request calls

2019-05-15 Thread Tim Watts
Hey Alex, Sounds like you would want to look at Django middleware, and raise a 404 if the request parameter is invalid. https://docs.djangoproject.com/en/2.2/topics/http/middleware/#exception-handling Tim On Wed, May 15, 2019 at 1:09 PM Alexander Lamas wrote: > Hi all, > > Does anyone know ho