[Answered ]-How do i get to collect static files ? i cant run this project it raises the error

2👍

STATIC_ROOT = os.path.join(BASE_DIR, '/static/') should be:

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

The / resets tree and it looks for static dir in the root, i.e. literally: /static where you want to have something like /home/user/project/static

STATIC_URL = '/static/' 
STATIC_ROOT = os.path.join(BASE_DIR, 'static/') 
STATICFILES_DIRS = ( "/home/mark/Desktop/xls/python-django-exporting-files/static‌​", ) 
try: 
  from local_settings import * 
except: 
  pass

STATICFILES_DIRS is a place where you keep your own static files that should be collected with collectstatic. It cannot be the same as STATIC_ROOT.

Your structure with static can be like

DJANGO_PROJECT_DIR
|--> PROJECT_DIR
|----> settings.py
|----> templates
|----> static
|--> static
|--> manage.py

Then the code will be (replace PROJECT_DIR with your project dir name):

STATIC_URL = '/static/' 
STATIC_ROOT = os.path.join(BASE_DIR, 'static') 
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'PROJECT_DIR', 'static‌'), ) 
try: 
  from local_settings import * 
except: 
  pass

Leave a comment