Reputation: 21
Hi I just moved my Django project on the docker. And created an image successfully. But when,I tried running it using
docker run -p 8000:8000 my-django-app
I am getting the error
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/usr/local/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'bootstrap5'
I have even added the bootstrap5 in the django settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'firstapp',
'bootstrap5',
]
And I have added it in the requriments.txt
django-bootstrap5==23.3
This if my dockerfile
# Use an official Python runtime as the base image
FROM python:3.11.1
# Set the working directory in the container
WORKDIR /app
# Copy the requirements.txt file and install the Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . /app/
# Expose the port the Django application will run on
EXPOSE 8000
# Set the command to start the Django development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
I have installed it using
pip install django-bootstrap-v5
I checked the version of the bootstrap5 as well as the settings.py but everything seems fine. I am trying to move this existing django project on the docker.
Upvotes: 1
Views: 749
Reputation: 1981
django-bootstrap5 and django-bootstrap-v5 these are different packages. And which is using different app names as well.
In your case you have installed django-bootstrap-v5
but in the requirements.txt
you mentioned django-bootstrap5==23.3
.
You need to updated it as django-bootstrap-v5==1.0.11
.
Use this command to generate requirements.txt
with lists of all the dependencies.
pip freeze > requirements.txt
Note : Adding/updating the requirements.txt manually is generally not recommended. It may leads to inconsistencies in the package versions. Instead it is best to generate it automatically.
Upvotes: 0