Reputation: 29
when I run the command django-admin collectstatic
in terminal i'm getting the following error:
ModuleNotFoundError: No module named 'mysite'
it even appears at the end of the list django-admin
commands help
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: No module named 'mysite').
myProject
|
+----mysite
| |
| +----settings.py
| +----wsgi.py
| +----urls.py
|
|
+----todo (app)
|
+----accounts(app)
|
+----myvenv
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
WSGI_APPLICATION = 'mysite.wsgi.application'
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()
Upvotes: 2
Views: 2104
Reputation: 262
Change directory into myProject, if not already there:
cd myProject
Set the required environment variables:
export DJANGO_SETTINGS_MODULE=mysite.settings
export PYTHONPATH=$(pwd)
Run django-admin:
django-admin
Upvotes: 0
Reputation: 4254
instead of django-admin collectstatic
use this command
python manage.py collectstatic
refer to this topic https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-and-manage-py
Upvotes: 2