django-api-framework icon indicating copy to clipboard operation
django-api-framework copied to clipboard

list index out of range Error when getting module names on app init

Open tyanas opened this issue 1 year ago • 0 comments

https://github.com/freemindcore/django-api-framework/blob/f4fd0ff27775a87a912544280c9ae8fc0c6ea26f/easy/main.py#L99

Stack trace

# 2024-08-14 17:25:22   File "/usr/local/lib/python3.12/site-packages/easy/main.py", line 99, in auto_create_admin_controllers
# 2024-08-14 17:25:22     model, app_module.name.split(".")[1]
# 2024-08-14 17:25:22            ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
# 2024-08-14 17:25:22 IndexError: list index out of range

requirements.txt

Django=5.0.1
...
django-api-framework==0.2.0 # easy BUGS

Context: python manage.py shell

>>> from django.apps import apps
>>> items = apps.app_configs.items()
>>> [x[0] for x in items]
['admin', 'auth', 'contenttypes', 'sessions', 'messages', 'staticfiles', 'allauth', '...,'rest_framework', 'users',...]

A possible solution would be to use app_module[0] instead of app_module.name.split(".")[1] in easy/main.py#L99

tyanas avatar Aug 15 '24 08:08 tyanas