I'm in process of upgrading an existing project. After upgrading arrow
to 0.17.0, it starts throwing an exception when on attribute of months
.
The issue goes away if downgrade arrow
to 0.13.x; but I hope to upgrade to the latest version and fix the issue in the good way. Any input will be highly appreciated.
...
File "/data/app/PROJECT/projectapp/rest/views.py", line 219, in get_precache_redeemable_codes
create_ts__gte=arrow.now().replace(months=-1).datetime))
File "/data/app/venv3.7/lib/python3.7/site-packages/arrow/arrow.py", line 807, in replace
raise AttributeError('unknown attribute: "{}"'.format(key))
AttributeError: unknown attribute: "months"
In my application source code, the triggering function call is:
create_ts__gte=arrow.now().replace(months=-1).datetime))
.select_related('customer')
.prefetch_related('orderitem_set')
The full trace of exception:
[27/Jan/2021 14:44:32] ERROR [django.request:230] Internal Server Error: /api/redeem/precache/
Traceback (most recent call last):
File "/data/app/venv3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/data/app/venv3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/data/app/venv3.7/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/data/app/venv3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/data/app/venv3.7/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/data/app/venv3.7/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/data/app/venv3.7/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/data/app/venv3.7/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/data/app/venv3.7/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
File "/data/app/PROJECT/projectapp/rest/views.py", line 219, in get_precache_redeemable_codes
create_ts__gte=arrow.now().replace(months=-1).datetime))
File "/data/app/venv3.7/lib/python3.7/site-packages/arrow/arrow.py", line 807, in replace
raise AttributeError('unknown attribute: "{}"'.format(key))
AttributeError: unknown attribute: "months"
question from:
https://stackoverflow.com/questions/65934136/python-library-arrow-throws-attributeerror-unknown-attribute-months