[Django]-Why it shows Unknown command: 'collectstatic', when I try to collect-static

8👍

Thank you for those who checked my question.
My problem is solved as I run the following code.

export DJANGO_SETTINGS_MODULE=mysite.settings

I found it from Django documentation.
But I still did not find out what was the real problem.
It was something about my settings file. or multiple settings files

so, if anyone know the details, please describe it here. or in personal.

0👍

I think you should uncomment STATIC_ROOT inside your settings.py file and try this:

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

0👍

First of all please check if there is a folder in base directory named ‘static’; if yes, then make a little change in the following code, remove’/’ after static:

STATIC_ROOT = os.path.join(BASE_DIR, 'static') 

Secondly, make sure you have registered all the apps in the installed apps menu.

If the problem still persists, then try to run the following command: python manage.py shell

It should let you know where the problem is, if it’s in the settings.

0👍

Try with replacing STATIC_ROOT in settings.py file with the following:

STATIC_ROOT = '/static/'

and whenever you run the python3 manage.py collectstatic command, make sure you are in the base directory where the manage.py file is located and there is a folder named static.

Leave a comment