Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

Stackorigin – The Community of Question and Answers

Stackorigin – The Community of Question and Answers Logo Stackorigin – The Community of Question and Answers Logo
Search
Ask A Question

Mobile menu

Close
Ask a Question
Home/ Questions/Q 25711
Next
In Process
hari
  • 0
hari
Asked: October 8, 20212021-10-08T05:54:56+00:00 2021-10-08T05:54:56+00:00In: Programming

Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT

  • 0

Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT

mediastatic
  • 1 1 Answer
  • 39 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Related Questions

    • How do you restart Apache?
    • aws s3 sdk returns "You have attempted to create more buckets than allowed"
    • What does ETL mean?
    • Is Apache running on my server?
    • Ways to Check Apache Server Status
    • Alternatives for Apache HTTP Server
    • How to access bitbucket using app password
    • How do I undo the most recent local commits in Git?
    • How do I rename both a Git local and remote branch name?
    • How do I rename a local Git branch?

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. ashok
      2021-10-08T05:59:34+00:00Added an answer on October 8, 2021 at 5:59 am
      This answer was edited.

      Development: STATIC_ROOT is useless during development, it’s only required for deployment. While in development, STATIC_ROOT does nothing. You even don’t need to set it. Django looks for static files inside each app’s directory (myProject/appName/static) and serves them automatically. This is the magic done by manage.py runserver when DEBUG=True. Deployment

      Development

      STATIC_ROOT is useless during development, it’s only required for deployment. While in development, STATIC_ROOT does nothing. You even don’t need to set it. Django looks for static files inside each app’s directory (myProject/appName/static) and serves them automatically. This is the magic done by manage.py runserver when DEBUG=True.

      Deployment

      When your project goes live, things differ. Most likely you will serve dynamic content using Django and static files will be served by Nginx. Why? Because Nginx is incredibly efficient and will reduce the workload off Django. This is where STATIC_ROOT becomes handy, as Nginx doesn’t know anything about your django project and doesn’t know where to find static files. So you set STATIC_ROOT = '/some/folder/' and tell Nginx to look for static files in /some/folder/. Then you run manage.py collectstatic and Django will copy static files from all the apps you have to /some/folder/. Extra directories for static files: STATICFILES_DIRS is used to include additional directories for collectstatic to look for. For example, by default, Django doesn’t recognize /myProject/static/. So you can include it yourself.

      STATIC_URL = '/static/'
      
      if not DEBUG: 
          STATIC_ROOT = '/home/django/www-data/site.com/static/'
      
      STATICFILES_DIRS = [
          os.path.join(BASE_DIR, 'static/'),
      ]
       MEDIA_ROOT is the folder where files uploaded using FileField will go. STATIC_ROOT is the folder where static files will be stored after using manage.py collectstatic

      STATICFILES_DIRS is the list of folders where Django will search for additional static files aside from the static folder of each app installed.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Ask A Question

    Stats

    • Questions 1k
    • Answers 1k
    • Best Answers 75
    • Users 72

    Adv 250x250

    Adv 234x60

    • Recent
    • Answers
    • zhengwei

      What is oil spill management?

      • 0 Answers
    • ashok

      How do you restart Apache?

      • 1 Answer
    • zhengwei

      How does a spill pallet work

      • 1 Answer
    • zhengwei

      What is floating booms

      • 1 Answer
    • ashok

      aws s3 sdk returns "You have attempted to create more ...

      • 1 Answer
    • hari
      hari added an answer Ubuntu way: To restart: sudo service apache2 restart To stop:… May 13, 2022 at 9:34 am
    • zhengwei
      zhengwei added an answer 1. Use with forklift: when using manual hydraulic forklift, mechanical… May 13, 2022 at 6:58 am
    • royyu
      royyu added an answer The solid float welded PVC oil containment boom is a universal horizontal… May 12, 2022 at 7:54 am
    • hari
      hari added an answer By default, an AWS account is soft limited to 100… May 11, 2022 at 3:15 pm
    • royyu
      royyu added an answer The oil leakage kit contains corresponding leakage emergency treatment materials,… May 11, 2022 at 6:27 am

    New Members

    clarkegable

    clarkegable

    • 0 Questions
    • 0 Answers
    Wellness Resort in Rishikesh

    Wellness Resort in Rishikesh

    • 0 Questions
    • 0 Answers
    Best IVF Hospital in Delhi

    Best IVF Hospital in Delhi

    • 0 Questions
    • 0 Answers
    Mohammedtaufiqumar

    Mohammedtaufiqumar

    • 1 Question
    • 0 Answers
    trademark search online

    trademark search online

    • 0 Questions
    • 0 Answers

    Adv 234x60

    Trending Categories

    Programming
    802Questions
    , 0Followers
    Technology
    208Questions
    , 3Followers
    General Knowledge
    103Questions
    , 0Followers
    Business & Finance
    81Questions
    , 4Followers
    Health
    72Questions
    , 3Followers

    Trending Tags

    django (94) git (47) google (29) health (21) india (35) mysql (22) oil (35) python (237) usa (25) youtube (23)

    Recent posts

      • On: May 13, 2022

      How to Start, Stop, or Restart Apache Server on Ubuntu

      • On: May 13, 2022

      How to Install Apache on Ubuntu

      • On: May 5, 2022

      CORS in Django REST Framework

      • On: April 30, 2022

      The most secure VPN services

      • On: April 30, 2022

      Best Websites to Watch Dragon Ball Z Online

    Explore Our Blog

    Adv 234x60

    Subscribe

    Explore

    • Recent Questions
    • Most Answered
    • Answers
    • No Answers
    • Most Visited
    • Most Voted
    • Random

    Footer

    Stackorigin - The Community of Question and Answers

    Stackorigin

    Stackorigin is the world’s largest Q&A networking site, Stackorigin community brings you the collaboration of all the various Questions and the related Answers given by the community.

    About

    • About Us
    • Contact Us
    • FAQ
    • Guest Post Article

    Info

    • Privacy Policy
    • Terms and Conditions
    • Community Guidelines
    • Tags

    Products

    • Tutorials
    • Advertising
    • Categories
    • Corona
    • StackHow

    Follow

    © 2022 Stackorigin. All Rights Reserved.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.