set django static root

  1. In the settings.py file of your Django project, first import the os module using the following line of code: import os

  2. Then, define the base directory of your project using the following line: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

  3. After that, define the STATIC_ROOT variable and set its value to the directory where you want to collect all your static files using the following line: STATIC_ROOT = os.path.join(BASE_DIR, 'static')

  4. Finally, make sure you have run the python manage.py collectstatic command to gather all your static files into the specified directory.