Hello everyone, 

I've recently needed to force the active Django language depending on the 
user's profile, however since this oauth-token-based auth is done only at 
DRF-view level, I couldn't resolve it with a normal Django middleware.

It seems to be a recurring problem (ex. 
https://github.com/jpadilla/django-rest-framework-jwt/issues/45), when 
django middelware don't have enough access to DRF data, and DRF itself 
doesn't seem to provide application-global hooks to interact with requests 
(ex. to enforce some constraints or validation on query params, on current 
language, etc.).

I've seen solutions using mixins (but it requires edit access to all used 
views), or using filters (but it looks like hacks). And since several 
features (like user auth) sem to be lazy/on-demand, even a custom 
authentication backend wouldn't necessarily solve my own issue in all cases.

Have there already been discussions on some DRF-level hook system, similar 
to Django's MIDDELWARE setting ? Or am I missing something already in place 
?  
(for now people are backporting DRF features like JWT or oauth to 
middelwares, but it makes duplicate DB calls, and duplicates app logic, so 
it's not entirely satisfying imo)

thanks in advance for your input !

regards,
Pascal

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/b6671fe2-02d7-46a8-a5b3-16b6e6d0d841o%40googlegroups.com.

Reply via email to