Unable to perform collectstatic

前端 未结 7 1256
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 02:42

I am new to django ! When I use the command python manage.py collectstatic I get this error

django.core.exceptions.ImproperlyConfigured: You\'re usi         


        
相关标签:
7条回答
  • 2021-01-30 03:24
    STATIC_ROOT = os.path.join(BASE_DIR, 'assest')
    STATICFILES_DIR = [
    os.path.join(BASE_DIR, 'static')
    ]
    
    0 讨论(0)
  • 2021-01-30 03:26

    well had this error as well. I fixed:

    STATIC_URL = '/static/'
    if DEBUG:
       STATICFILES_DIRS = [
       os.path.join(BASE_DIR, 'static'),
       ]
    else:
       STATIC_ROOT = os.path.join(BASE_DIR,'static')
    
    MEDIA_URL = '/media/'
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
    
    0 讨论(0)
  • 2021-01-30 03:40

    I had to put STATIC_ROOT and STATIC_URL above the STATICFILES_DIRS declaration.

    0 讨论(0)
  • 2021-01-30 03:44

    Try this,

    PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
    STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
    

    Look at https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATIC_ROOT

    0 讨论(0)
  • 2021-01-30 03:45

    you can create 'static' folder in any subfolder and have required files in it. In settings.py add the following lines of code:

    PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
    STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
    STATIC_URL = '/static/'
    

    After running python manage.py collectstatic a new static folder will be created in your parent App folder

    0 讨论(0)
  • 2021-01-30 03:47

    You must have to give path in STATIC_ROOT in settings.py where all your static files are collected as for example:-

    STATIC_ROOT = "app-root/repo/wsgi/static"
    
    STATIC_URL = '/static/'
    
    STATICFILES_DIRS = (
        ('assets', 'app-root/repo/wsgi/openshift/static'),
    
        )
    
    0 讨论(0)
提交回复
热议问题