explain
brahim024 opened this issue · 1 comments
Line 139 in f3fc911
I'm a bit unclear on the context, but it sounds like you're trying to retrieve setting names from the object itself (self) rather than from the overridden settings dictionary.
can someone exaplain that please
I wasn't here when it was created and it looks weird indeed, but after looking deeper into it I think it's brilliant.
Lines 121 to 124 in f3fc911
This allows us to obtain the settings either from django settings, or whenever they are updated (override_settings
decorator etc) using the signal. It's just a dict.
Line 139 in f3fc911
I assume this case you're asking about is important only on update (whenever the signal is fired up), as this allows us to update the dictionary that's already set on self
.
In the next line, it updates the existing dict (value
) with these new values.
This allows us to import Djoser settings directly and use it within the Djoser project.
https://github.com/search?q=repo%3Asunscrapers%2Fdjoser+%22+settings.%22+path%3A*.py&type=code
Here, settings
, is literally the instance of this Settings
class, with attributes set with setattr
onto it.
DRF uses a similar approach. See https://github.com/encode/django-rest-framework/blob/1db19f4b2d1500894448634852e02f73043382e4/rest_framework/settings.py#L197-L198