Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django-admin collectstatic is an unknown command

Tags:

django

Trying to collect my static files as I will be deploying my website soon. Receiving:

Unknown command: 'collectstatic'

After checking django-admin help I receive this warning:

(error: Requested setting INSTALLED_APPS, but settings are not configured. 
 You must either define the environment variable DJANGO_SETTINGS_MODULE or call 
 settings.configure() before accessing settings.).

Here is my manage.py:

def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'xwordsite.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)

I have tried running manage.py shell, which did not solve the issue. Also I'm unsure if it matters but all my static files are in the project dir. Also static settings:

STATIC_URL = '/static/'
STATIC_ROOT = "C:/Users/Joseph/Desktop/xwordsite/static"
like image 404
Joeyboy Avatar asked Sep 06 '25 03:09

Joeyboy


1 Answers

As per the docs:

Just write python manage.py collectstatic and it will work.

like image 149
Bernardo Duarte Avatar answered Sep 07 '25 22:09

Bernardo Duarte