UnicodeEncodeError Ubuntu, Apache2, Admin page

Hi, I have a problem with utf-8 encoding.

When I load models in admin page i get

Internal Server Error: "<MY_ENDPOINT>"
Traceback (most recent call last):
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/response.py", line 90, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/response.py", line 72, in resolve_template
    return select_template(template, using=self.using)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/loader.py", line 42, in select_template
    return engine.get_template(template_name)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/backends/django.py", line 33, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/engine.py", line 177, in get_template
    template, origin = self.find_template(template_name)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/engine.py", line 159, in find_template
    template = loader.get_template(name, skip=skip)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/loaders/cached.py", line 57, in get_template
    template = super().get_template(template_name, skip)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/loaders/base.py", line 23, in get_template
    contents = self.get_contents(origin)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/loaders/cached.py", line 26, in get_contents
    return origin.loader.get_contents(origin)
  File "/home/jeppe/miniconda3/envs/Django/lib/python3.10/site-packages/django/template/loaders/filesystem.py", line 22, in get_contents
    with open(origin.name, encoding=self.engine.file_charset) as fp:
UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 69: ordinal not in range(128)

File name that contains åäö is some migrations files.

I run ubuntu server with apache2.

When I load same models in normal views it works and url with åäö works to.

It works when i run dev env with production DB.

I have set AddDefaultCharset UTF-8 in apache2
Ubuntu locale --> LANG=sv_SE.UTF-8...

in settings.py

DEFAULT_CHARSET = 'utf-8'
FILE_CHARSET = 'utf-8

I dont understand why self.engine.file_charset == ascii?
Why can’t django/apache read utf8 chars in file name?
Why can windows/manage.py runserver handle the utf8 file names?
Why do I only get this in the admin page?

Sincerely, Jesper

Finally found the problem.

I can’t answer why the app works as normal if I don’t use the admin page.
My guess is that the admin page read files a bit different.
Now, however, the admin page loads all the models as well.

In /etc/apache2/envvars :
From

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

To

## The locale used by some modules like mod_dav
#export LANG=C
## Uncomment the following line to use the system default locale instead:
. /etc/default/locale

export LANG