Python Forum
Hello I’m trying to run a Django python project on docker but when I try to build the
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello I’m trying to run a Django python project on docker but when I try to build the
#1
Hello I’m trying to run a Django python project on docker but when I try to build the Dockerfile I get this error:

Note that only Django core commands are listed as settings are not properly configured (error: No module named ‘settings’).

This is the Dockerfile:

FROM python:3

ADD manage.py /

COPY requirements.txt /tmp
WORKDIR /tmp
RUN pip install -r requirements.txt 

WORKDIR / 

CMD [ "python", "manage.py" ]
However when I run the command

python manage.py 
I get no errors and the settings file is loaded correctly… So I guess that my computer does know that the file exists but can’t acknowledge it through docker for some reason ?

This is my manage .py file:

import os
import sys


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
I’m a beginner and have been stuck on this for some days now, I looked for solutions online but they didn’t work… I will really appreciate your help!
Reply
#2
Did you migrate the changes made in project?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with new Django Project card51shor 12 6,939 Jul-04-2020, 07:44 AM
Last Post: card51shor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020