Error while running pytest for my project in circleCI: Requested setting INSTALLED_APPS or could not find a Django project

Hello,

I am new to circleCI, I had already made an attempt and had gone through Travis but for this project I want to use circleCi. I work with Django, Python and I use pytest-django for my test. Locally, my tests work well, the ci works until the flake8 command and I have the error on pytest.

  • Either it tells me Requested setting INSTALLED_APPS, but settings are not configured.You must either define the environment variable DJANGO_SETTINGS_MODULE

  • Either, if I add the environment variable for DJANGO_SETTINGS_MODULE, It tells me: pytest-django could not find a Django project (no manage.py file could be found)

below is my config.yml with the default conf and my addition code.

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
  say-hello:
    # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
    # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
    docker:
      - image: cimg/base:stable
    # Add steps to the job
    # See: https://circleci.com/docs/2.0/configuration-reference/#steps
    steps:
      - checkout
      - run:
          name: "Say hello"
          command: "echo Hello, World!"

  test_osteoapp:
    environment:
      DJANGO_SETTINGS_MODULE: apposteo.settings
    docker:
      - image: cimg/python:3.9.0
    steps:
      - checkout
      - run:
          name: requirements
          command: pip install -r requirements.txt
      - run:
          name: flake
          command: flake8
      - run:
          name: test_execute
          command: pytest

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
  say-hello-workflow:
    jobs:
      - say-hello
  test-app-workflow:
    jobs:
      - test_osteoapp

Thanking you in advance for the help you can give me, I remain at your disposal for any additional information. If I left the default say-hello job in the file, it was to keep an example of a working conf in front of me.

Hello,
I’m updating and going to pass the topic in closed. The problem came from the fact that my manage.py file was in a tree subfolder:
MyProject:
|
-pipfile
-requirements.txt
-readme…
-src
|
----app
----app
----manage.py
Should have given yml the path to the manage.py but I couldn’t find/understand how. So I changed my tree to put the app and the manage.py at the root of the project. I just got around the issue. I’ll look when I have more time because I still find it a little cleaner to have my apps in another folder.