Thursday, September 29, 2022

Re: Hierarchy for Docker Files / "docker-compose up" issue — Question re: Chapter 2 of Django for Professionals

Can you also share your docker-compose.yml file as well? It seems to be calling your django_project folder but can't seem to find it, even though the Dockerfile clearly shows that its copied.

On Fri, Sep 9, 2022 at 5:19 AM Stephanie Goulet <stephanie.a.goulet@gmail.com> wrote:
Thanks so much, Francisco. I'm doing something wrong that makes the "docker-compose up" not work to begin with. More detail, including the traceback text below:

Dockerfile & .dockerignore match the text in Ch 2 of the book Django for Professionals; here they are just in case that's helpful:



Traceback text:

(.venv) stephaniegoulet@Stephanies-MacBook-Pro ch2-hello % docker-compose up

Creating network "code2_default" with the default driver

Creating code2_web_1 ... done

Attaching to code2_web_1

web_1  | Traceback (most recent call last):

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv

web_1  |     self.execute(*args, **cmd_options)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 74, in execute

web_1  |     super().execute(*args, **options)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute

web_1  |     output = self.handle(*args, **options)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 81, in handle

web_1  |     if not settings.DEBUG and not settings.ALLOWED_HOSTS:

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__

web_1  |     self._setup(name)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup

web_1  |     self._wrapped = Settings(settings_module)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__

web_1  |     mod = importlib.import_module(self.SETTINGS_MODULE)

web_1  |   File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module

web_1  |     return _bootstrap._gcd_import(name[level:], package, level)

web_1  |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

web_1  |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

web_1  |   File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked

web_1  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed

web_1  |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

web_1  |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

web_1  |   File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

web_1  | ModuleNotFoundError: No module named 'django_project'

web_1  | 

web_1  | During handling of the above exception, another exception occurred:

web_1  | 

web_1  | Traceback (most recent call last):

web_1  |   File "/code2/manage.py", line 22, in <module>

web_1  |     main()

web_1  |   File "/code2/manage.py", line 18, in main

web_1  |     execute_from_command_line(sys.argv)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line

web_1  |     utility.execute()

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute

web_1  |     self.fetch_command(subcommand).run_from_argv(self.argv)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 427, in run_from_argv

web_1  |     connections.close_all()

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/db/utils.py", line 212, in close_all

web_1  |     for alias in self:

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/connection.py", line 73, in __iter__

web_1  |     return iter(self.settings)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 49, in __get__

web_1  |     res = instance.__dict__[self.name] = self.func(instance)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/connection.py", line 45, in settings

web_1  |     self._settings = self.configure_settings(self._settings)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/db/utils.py", line 148, in configure_settings

web_1  |     databases = super().configure_settings(databases)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/connection.py", line 50, in configure_settings

web_1  |     settings = getattr(django_settings, self.settings_name)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__

web_1  |     self._setup(name)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup

web_1  |     self._wrapped = Settings(settings_module)

web_1  |   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__

web_1  |     mod = importlib.import_module(self.SETTINGS_MODULE)

web_1  |   File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module

web_1  |     return _bootstrap._gcd_import(name[level:], package, level)

web_1  |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

web_1  |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

web_1  |   File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked

web_1  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed

web_1  |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

web_1  |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

web_1  |   File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

web_1  | ModuleNotFoundError: No module named 'django_project'

code2_web_1 exited with code 1

(.venv) stephaniegoulet@Stephanies-MacBook-Pro ch2-hello % 





On Thu, Sep 8, 2022 at 4:50 PM Francisco Valadares <valadares.dev@gmail.com> wrote:
  Hello Stephanie,

All the last six files can stay where they are (no problem). Observer if the commands in the Dockerfile file are copying the module(django_project) into the image. After you start the containner(docker-compose up) you could acess it with "docker exec -it <name container> sh".

How is your dockerfile and your .dockerignore?

Stephanie Goulet <stephanie.a.goulet@gmail.com> escreveu no dia quinta, 8/09/2022 à(s) 14:27:
Hi all, any help would be appreciated:

Question:
  1. In the below screenshot of VSC, are the last six files all in the right hierarchical place? In other words, should any of those be within either the "django_project" or "pages" folders? If so, which files should go in which level folder?


Context:
  • I'm new to this 
  • To learn, I went through the book Django for Beginners and am now working through Django for Professionals
  • I'm on page 29 of Chapter 2: Docker Hello, World! in the Django for Professionals PDF
  • It seems like I successfully did the "docker build ." command, but I'm running into trouble with the "docker-compose up" command. It's giving some traceback errors and a line that says "ModuleNotFoundError: No module named 'django_project'" which is why I suspect that I may have saved some of the files in the wrong place (maybe all of them belong in the 'django_project' folder?).
Thank you in advance!

Best,
Stephanie

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2e1368cf-cee9-4aac-a74b-d727094b4f36n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/ILI31w5H_QQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA-J3id6ZLCyONOqNx2Tdbyv3vR_g%3DBpYt-PEzTnGKqbV%2BTJTQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAM8_Wzst99v%2BJGQp-Hg4zwxTMvsNTWDhPK8y3dMFFJuY-9MrFA%40mail.gmail.com.


--
Abdul Qoyyuum Haji Abdul Kadir
about.me/qoyyuum

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANVqoJ-qiwK1U5QZjo%2B4VSZiD8kw8kRnauqgyRoijpfcscRROQ%40mail.gmail.com.

No comments:

Post a Comment