django-rosetta icon indicating copy to clipboard operation
django-rosetta copied to clipboard

TypeError at../rosetta/files/project

Open allanon74 opened this issue 1 year ago • 3 comments

Django: 5.0.1 django-rosetta: 0.10.0

I tried to access to the rosetta admin page (through the admin page) and i received that error:

TypeError at /it/rosetta/files/project/ Expected str, bytes or os.PathLike object, not NoneType

traceback

Environment:

Request Method: GET Request URL: http://leiferstsdjango.leifers.gvcc.net/it/rosetta/files/project/

Django Version: 5.0.1 Python Version: 3.10.12 Installed Applications: ['tabella.apps.TabellaConfig', 'turni.apps.TurniConfig', 'dipendenti.apps.DipendentiConfig', 'valutazioni.apps.ValutazioniConfig', 'pratiche.apps.PraticheConfig', 'helpdesk.apps.HelpdeskConfig', 'accessi.apps.AccessiConfig', 'gic.apps.GicConfig', 'admin_interface', 'colorfield', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', 'django.forms', 'simple_history', 'webpush', 'rosetta', 'parler', 'fontawesomefree'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.admindocs.middleware.XViewMiddleware', 'simple_history.middleware.HistoryRequestMiddleware']

Traceback (most recent call last): File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/utils/decorators.py", line 48, in _wrapper return bound_method(*args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper response = view_func(request, *args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/utils/decorators.py", line 48, in _wrapper return bound_method(*args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view return view_func(request, *args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/rosetta/views.py", line 57, in dispatch return super(RosettaBaseMixin, self).dispatch(*args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, *args, **kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/django/views/generic/base.py", line 226, in get context = self.get_context_data(**kwargs) File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/rosetta/views.py", line 213, in get_context_data po_paths = find_pos( File "/home/django/ambienti/laisoft/lib/python3.10/site-packages/rosetta/poutil.py", line 52, in find_pos os.path.abspath(os.path.dirname(project.file)) File "/usr/lib/python3.10/posixpath.py", line 152, in dirname p = os.fspath(p)

Exception Type: TypeError at /it/rosetta/files/project/ Exception Value: expected str, bytes or os.PathLike object, not NoneType

allanon74 avatar Jan 25 '24 09:01 allanon74

Hello, Rosetta is trying to find the path of your Django project. I think the problem is that it's missing an __init__.py in the main project dir (i.e. where manage.py lives). I'll look into this, but in the meantime you can probably fix the issue by creating that file.

mbi avatar Jan 25 '24 09:01 mbi

Note to self. project.__file__ is None if the project doesn't have an __init__.py file. https://github.com/mbi/django-rosetta/blob/develop/rosetta/poutil.py#L52

mbi avatar Jan 25 '24 09:01 mbi

ah ok! Thanks and sorry for the stupid question!

allanon74 avatar Jan 25 '24 13:01 allanon74