DEV Community

Discussion on: Setting up Django REST API with custom user model and tests

codebyline profile image
Yumei Leventhal • Edited on

I can't seem to get pytest to work. The file 'pytest.ini' and the folder 'tests' are both in the root directory -- is that correct? Here's part of the error:

venv/lib/python3.9/site-packages/django/conf/ in _setup
raise ImproperlyConfigured(
E django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

ksaaskil profile image
Kimmo Sääskilahti Author

Thanks for raising the issue! Have you checked your directory structure and pytest.ini exactly match the one in the accompanying repository? The github workflow seems to work fine 🤔

codebyline profile image
Yumei Leventhal

Thanks for responding! The error must have been on my end. I moved 'pytest.ini' in and out of the 'tests' folder and now everything works. Thank you very much!