0

When executing the command 'collectstatic', python looks into the wrong folder, Dev/staticfiles, when my staticfiles are saved in the folder: [..]/Dev/bidding_tool_project/project/staticfiles

Would you have any idea how/why this happens?

Ben
  • 177
  • 1
  • 2
  • 9
  • Please, can you show your `STATIC_ROOT` setting (if you have specified)? – Dipen Dadhaniya Oct 14 '19 at 06:50
  • Sure: `STATIC_ROOT = os.path.join(PROJECT_ROOT, 'project/staticfiles')`, where `PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))`. – Ben Oct 14 '19 at 07:05
  • Exactly which commands did you use in the terminal and the Python console? – Dipen Dadhaniya Oct 14 '19 at 07:15
  • in my settings module, I have added the line: `print('STATIC_ROOT:', STATIC_ROOT)` and in the python console: - `from project import settings` - `settings.STATIC_ROOT` – Ben Oct 14 '19 at 07:20
  • I doubt that from the console, you are improting another project's settings module. Are you sure it is not the case? – Dipen Dadhaniya Oct 14 '19 at 08:03
  • I thought this could be a reason and so I saved the settings module into a specific folder (`project`), within my larger project (`xxx_project`) but the error persisted. I don't think I am importing from an other project. I tried again just now creating a brand new project from scratch and have the same issue again: the name of the root folder is missing – Ben Oct 14 '19 at 08:07
  • Wait, so the issue is `the name of the root folder is missing`, or it is giving an incorrect value? I think in the question, you have mentioned it is giving an incorrect value. – Dipen Dadhaniya Oct 14 '19 at 08:15
  • Apologies what I meant was the path was not correct. In my initial statement / question, you will see that the path displayed is not the same in each case (STATIC_ROOT from within the settings module and settings.STATIC_ROOT as shown in the python console) where i would expect them to be exactly equal – Ben Oct 14 '19 at 08:38

1 Answers1

0

An other SO answer helped: os.path.join considers anything after a slash as being an absolute path. When using os.path.join, the path should be declared as: STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') and not STATIC_ROOT = os.path.join(BASE_DIR, 'project/staticfiles')

the post that helped me: Why doesn't os.path.join() work in this case?

Ben
  • 177
  • 1
  • 2
  • 9