Reputation: 472
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"
Upvotes: 4
Views: 2159
Reputation: 46
In this page, at first says django-admin collectstatic
but end of the section there is a code block that says manage.py collectstatic
. At first it confused me. I did try to solve this error and tried to configure settings etc. which did not worked.
After all these effort, suddenly it hit me and i wrote manage.py collectstatic
and it worked.
Upvotes: 2
Reputation: 4264
As per the docs:
Just write python manage.py collectstatic
and it will work.
Upvotes: 5