Is there a place for user defined settings? Stuff that isn't going to
change that often, but still might need to be tweaked from time to time?
Here's the scenario. I'm creating objects, and I'm setting an expiration
date X days in the future. I have a custom create function in my serializer
setting the "expiration" field to the future date, and it's working well.
Everything is getting set correctly.
validated_data['expiration'] = datetime.datetime.now( datetime.timezone.utc
) + datetime.timedelta( days=40 )
The problem is, the code needs to be changed if I want to raise or lower
the time the objects are stored, and I would like to move this into a
config file to make it easier to work with. It's a system wide setting, and
the admin gets to pick how long the objects are stored.
I found the settings page in the docs, and it works fine with existing
variables. It doesn't work when I add my own variables. This does not work.
settings.py:
RET_FRAMEWORK = {
...
'OBJEXP': 4,
}
serializers.py:
days = api_settings.OBJEXP
validated_data['expiration'] =
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=days)
What am I missing?
Thanks in advance!
Ryan
--
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/f4f4f62d-df06-49da-8967-94f7d7cb5faf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.