Project Mercury Web Application

Dear @mmumshad

I can’t get the web application in the last practice test in the Linux Basics working.

I follow all steps correctly but I get this error I can’t find a way to solve it, can you please have a look on this problem? thank you in advance.

start application get error :

web application:

Best Regards
Youness

@youness.oujdid , Thanks for pointing this out. We will check this.

I am also getting the same issue

I just did the full lab; it works for me. So if you will please give me some additional information about what you did and what isn’t working for you, we’ll see where you need to fix something. What step were you on when it failed for you, what did you do, and and what errors are you seeing?

Hy I have multiple issue in this lab. I tried 3 times still no success.

  1. During the first try the (venv) step was success, but after I started the app, I always got an error “templateNotFound home.html”
  2. During the next two try I got the same error during env activation, but this was not a fail during the first try.
bob@devapp01:/opt/caleston-code$ source venv/bin/activate
(venv) bob@devapp01:/opt/caleston-code$ python3 manage.py migrate
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 361, in execute
    self.check()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 64, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "/usr/local/lib/python3.6/dist-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.6/dist-packages/django/core/checks/database.py", line 9, in check_database_backends
    for conn in connections.all():
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 216, in all
    return [self[alias] for alias in self]
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wordcountbasic'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 336, in run_from_argv
    connections.close_all()
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 219, in close_all
    for alias in self:
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wordcountbasic'

Hy

I tried again without success, What is the problem? What am I missing? Thank you.

15/17 says this one:

Great! Everything should now be in order to restart the application.

On the `devapp01` server start the webserver again by running the command:

1. Navigate to the directory `/opt/caleston-code/mercuryProject`
2. Next, run the command `python3 manage.py runserver 0.0.0.0:8000`

**Note:-** Make sure to activate the virtual environment using `source ../venv/bin/activate` within the current project before executing `python3 manage.py migrate`.

Something like `(venv)` should now be a part of the prompt.

To access the application, click on the `Project Mercury` tab!

I run the command 2 python3 manage.py runserver 0.0.0.0:8000 and it gives me the migration message (as expected I think).

bob@devapp01:~$ python3 /opt/caleston-code/mercuryProject/manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 19 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, blog, contenttypes, portfolios, sessions.
Run 'python manage.py migrate' to apply them.

January 08, 2025 - 17:58:27
Django version 2.2.6, using settings 'mercury.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

**Then I click the “Open Mercury Button” and it gives me this error

## Error during template rendering

In template `/opt/caleston-code/mercuryProject/templates/home.html`, error at line **52**

bob@devapp01:/opt/caleston-code/mercuryProject$ python3 manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 19 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, blog, contenttypes, portfolios, sessions.
Run 'python manage.py migrate' to apply them.

January 08, 2025 - 17:55:14
Django version 2.2.6, using settings 'mercury.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "portfolios_portfolios" does not exist
LINE 1: ..."."image", "portfolios_portfolios"."summary" FROM "portfolio...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/caleston-code/mercuryProject/portfolios/views.py", line 6, in home
    return render(request, 'home.html', {'portfolios': portfolios})
  File "/usr/local/lib/python3.6/dist-packages/django/shortcuts.py", line 36, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/usr/local/lib/python3.6/dist-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.6/dist-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/dist-packages/django/template/defaulttags.py", line 166, in render
    len_values = len(values)
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 256, in __len__
    self._fetch_all()
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/sql/compiler.py", line 1100, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "portfolios_portfolios" does not exist
LINE 1: ..."."image", "portfolios_portfolios"."summary" FROM "portfolio...
                                                             ^

[08/Jan/2025 17:55:19] "GET / HTTP/1.1" 500 160004

Next I run the activation (as I think it solves the problem) but it gives me this error:

(venv) bob@devapp01:/opt/caleston-code$ python3 manage.py migrate
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 361, in execute
    self.check()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 64, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "/usr/local/lib/python3.6/dist-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.6/dist-packages/django/core/checks/database.py", line 9, in check_database_backends
    for conn in connections.all():
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 216, in all
    return [self[alias] for alias in self]
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wordcountbasic'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 336, in run_from_argv
    connections.close_all()
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 219, in close_all
    for alias in self:
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wordcountbasic'

I found the solution in other post hire on the forum:

I thought about it, and I think I made a mistake during the venv configuration, I used

source venv/bin/activate

instead of

source ../venv/bin/activate

For a long time, I didn’t think that was why the error appeared.

Thanks for the course it was really good.