Cannot get Forest Admin to work on existing Django Project

Feature(s) impacted

After following the installation steps on an existing django projects with 5 apps and many models, I get and error when I run the server.

Observed behavior

I followed all the steps in the installation and cannot seem to connect to forest admin at the end of the installation process. Problem seems to happen when writing to the .forestadmin-schema.json file. I thought it had to do with some fields on my models being URLFields (I inspected the JSON and the validators regex seemed to cause issues).

I removed all the URLField and replaced them with CharField but didn’t work. Then the error seemed to point in the direction of DurationField I had (timedelta error). I changed all of them to CharField as well but still got the same error.

Expected behavior

I tried on an empty django project and after running the python3 runserver command, everything works fine and is connected to the forest admin UI with the local environment.

Failure Logs

❯ python3 runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
February 03, 2023 - 22:11:17
Django version 4.1.6, using settings 'docstring.settings'
Starting development server at
Quit the server with CONTROL-C.
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/", line 973, in _bootstrap_inner
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/sentry_sdk/integrations/", line 69, in run
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/sentry_sdk/", line 57, in reraise
    raise value
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/sentry_sdk/integrations/", line 67, in run
    return old_run_func(self, *a, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/utils/", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/core/management/commands/", line 157, in inner_run
    handler = self.get_handler(*args, **options)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/", line 31, in get_handler
    handler = super().get_handler(*args, **options)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/core/management/commands/", line 78, in get_handler
    return get_internal_wsgi_application()
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/core/servers/", line 47, in get_internal_wsgi_application
    return import_string(app_path)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/utils/", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django/utils/", line 15, in cached_import
    module = import_module(module_path)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/thibh/docstring/docstring/", line 17, in <module>
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django_forest/", line 14, in init_forest
  File "/Users/thibh/docstring/.env/lib/python3.9/site-packages/django_forest/utils/schema/", line 165, in handle_schema_file
    f.write(json.dumps(cls.schema_data, indent=2))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 234, in dumps
    return cls(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 201, in encode
    chunks = list(chunks)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 325, in _iterencode_list
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 325, in _iterencode_list
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 325, in _iterencode_list
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 438, in _iterencode
    o = _default(o)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type timedelta is not JSON serializable


  • Project name: DocstringFr

Django version : 4.1.6
Python version : 3.9.6

Hello @Thibault, welcome to our community :slight_smile:
Currently we can’t reproduce your issue, do you have a model to share with us to reproduce your issue on our end ? :pray: