Forums

Collecting statics Issue!

I can not link my statics, everything looks good but with no styling, my setting.py arrange the roots like this:

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
PROJECT_ROOT=os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT=os.path.join(PROJECT_ROOT,'static')
MEDIA_ROOT=os.path.join(STATIC_ROOT,'media')
MEDIA_URL='/media/'

and when i run the command: python manage.py collectstatic, i got the erroe said:

File "manage.py", line 14
    ) from exc
         ^
SyntaxError: invalid syntax

when i go to manage.py file the line 14 says:

import os
import sys

if __name__ == '__main__':
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Quotee.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)

now, the issues is the web app could not reach it's statics, could you help with that please.

[edit by admin: formatting]

It looks like you're running manage.py with Python 2.7, but your website is coded to use Python 3.x. If you're using a virtualenv, to run manage.py you should start a Bash console inside that virtualenv to run manage.py, either by using the link on the "Web" page or by starting a normal Bash console then running workon envname (replacing envname with the name of the virtualenv).

Thanks a lot giles , It is works now and responded to the command, but still the static files are not connected!.

22:16 ~/Quotee (master)$ workon myEnv
(myEnv) 22:17 ~/Quotee (master)$ python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
    /home/mortada/Quotee/Quotee/static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
136 static files copied to '/home/mortada/Quotee/Quotee/static'.

[edit by admin: formatting]

Right, now you need to set up the static files mapping on the "Web" page so that the server knows where to find them. This help page should explain everything you need.