DRF override settings during testing

41 views
Skip to first unread message

mohammad moghadas

unread,
Sep 17, 2020, 2:47:01 AM9/17/20
to Django REST framework
Hi guys
i'm trying to override `DEFAULT_FILTER_BACKEND` in tests. I've attempted 2 approaches which have caused to failure:
1- @override_settings decorator top of both method and class 
2- using with self.settings(REST_FRAMEWORK={...}) context manager
I don't know whether it needs to modify my views

please help me. thanks a lot 

Alan Crosswell

unread,
Sep 17, 2020, 9:57:27 AM9/17/20
to django-res...@googlegroups.com
It's plural:

grep -nr DEFAULT_FILTER_BACKEND rest_framework/settings.py 

rest_framework/settings.py:52:    'DEFAULT_FILTER_BACKENDS': [],

rest_framework/settings.py:141:    'DEFAULT_FILTER_BACKENDS',



--
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 django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/cc289acb-aac6-4af1-9ff4-261791c4cdc6n%40googlegroups.com.

Alan Crosswell

unread,
Sep 17, 2020, 9:59:40 AM9/17/20
to django-res...@googlegroups.com
Also, take a look in tests/ for examples like this:

@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'})

Reply all
Reply to author
Forward
0 new messages