Django plans cause error in sqlit3 backend

I have a web app hosted on and i have installed django plans in a virtualenv. my python version is 3.8 and django is 3.2.12. My app and plan section works fine so far, but recently my app encouter some nasty errors in django sqlite3 backend and plans as bellow. Error is in Decimal conversion but it start from plan views.

Internal Server Error: /
Traceback (most recent call last):
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/core/handlers/", line 34, in inner
    response = get_response(request)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/core/handlers/", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/core/handlers/", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/views/generic/", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/views/generic/", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/views/generic/", line 157, in get
    context = self.get_context_data()
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/plans/", line 120, in get_context_data
    context['plan_table'] = self.get_plan_table(self.object_list)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/plans/", line 74, in get_plan_table
    for plan in plan_list:
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 276, in __iter__
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 1263, in _fetch_all
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 782, in _prefetch_related_objects
    prefetch_related_objects(self._result_cache, *self._prefetch_related_lookups)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 1651, in prefetch_related_objects
    obj_list, additional_lookups = prefetch_one_level(obj_list, prefetcher, lookup, level)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 1764, in prefetch_one_level
    prefetcher.get_prefetch_queryset(instances, lookup.get_current_queryset(level)))
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/fields/", line 635, in get_prefetch_queryset
    for rel_obj in queryset:
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 276, in __iter__
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 1261, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/", line 74, in __iter__
    for row in compiler.results_iter(results):
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/models/sql/", line 1095, in apply_converters
    value = converter(value, expression, connection)
  File "/home/SocialAI/.virtualenvs/expertenv/lib/python3.8/site-packages/django/db/backends/sqlite3/", line 286, in converter
    return create_decimal(value).quantize(quantize_value, context=expression.output_field.context)
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

I post this error in pythonanywhere forum and django plans github issue section also,but so far no solution found for this issue.

If you’re talking about this package: django-plans · PyPI

It was last released in 2018, for Django 2.0 / Python 3.6. It’s quite possible that it’s not compatible with Django 3.2 / Python 3.8, and you’re running into a compatibility issue.

I see you’ve posted an issue on the github site - so that’s probably going to be your best chance for a solution unless you want to dig into the code yourself to find the cause of the problem.

Thanks for your reply. I think this error isn’t related to compatibility issues since same code is running well in my local version still, also my app workd fine for more than 18 months with same settings(python 3.8 and django 3.2.12). Indeed in django_plans githup page also informed master branch support django 2.2+ and python 3.6+
I believe key element of my app problem is in virtualenv, since my app works fine until unintended django upgrade to ver 4 happened in pythonanywhere system and caused some errors in django template backend. At first i tried to downgrade django version but some errors in django-admin occured and supports in forum advised to make virtualenv and reinstall all packages there. After that this error occurred and i tried remaking virtualenv and reinstalling django and django_plans also upgrading system image but same error remained.

Finally i found the solution and it was presaved records in database! So by deleting related records in datbase problem solved.
Just enabling “DEBUG=True” in app setting was required to control which data and value passed to functions