Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

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 a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8238263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:45:04+00:00 2026-06-07T19:45:04+00:00

This si my settings.py about static in settings.py : STATIC_ROOT = ‘/home/coat/www/site/app/static/’ STATIC_URL =

  • 0

This si my settings.py about static in settings.py:

STATIC_ROOT = '/home/coat/www/site/app/static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
"/usr/lib/python2.6/site-packages/django/contrib/admin/static/",
# This is Django admin default static files
)

I user django server:

./manager runserver

Then I open the URL: http://localhost:8000/static/admin/css/base.css

It works very well.

But a open http://localhost/static/admin/css/base.css

It print ‘404’

enter image description here

I had restart Nginx and uwsgi for many times, but it dosen’t works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:45:05+00:00Added an answer on June 7, 2026 at 7:45 pm

    First things first, this is nonono:

    STATIC_ROOT = '/home/coat/www/site/app/static/'
    

    Never hardcode absolute paths, you’re just making your settings file less portable and probably killing kittens. Adapt this to your needs:

    import os.path
    import posixpath
    
    PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')
    
    STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
    
    # fix STATICFILES_DIRS too
    

    Now, to your question. django.contrib.staticfiles is fantastic but probably a little confusing at first.

    1. You must understand the collectstatic command:

      Collects the static files into STATIC_ROOT. […] Files are searched by using the enabled finders. The default is to look in all locations defined in STATICFILES_DIRS and in the ‘static’ directory of apps specified by the INSTALLED_APPS setting.

    2. With runserver, staticfiles are served automatically, but in production mode (DEBUG=False, real HTTP server like Nginx), you should run collectstatic to (re)build STATIC_ROOT

    3. STATIC_ROOT: is the root path where the HTTP server should serve static files from.

    4. STATIC_URL: is the root URL where the HTTP server should serve static files to.

    5. STATICFILES_DIRS: other static directories, in addition to each app’s “static” subdirectory. Because django.contrib.admin is a normal app with a “static” folder, there is no need to specify it in the settings.

    Conclusion: if STATIC_ROOT resolves to /home/coat/www/site/app/static/, and STATIC_URL is /static/, then you should:

    1. Run collectstatic management command

    2. Configure Nginx to serve /home/coat/www/site/app/static/ on /static/, ie.:

      location ^~ /static/ {
          alias /home/coat/www/site/app/static/;
      }
      
    3. Reload nginx

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

Sidebar

Related Questions

First let me say that this is not about production settings for django -
I have a question about the following code: public Class Settings{ public static final
Well, I'm making my foray into this fantastic site with a question about the
I have a WordPress plugin with settings page. On this settings page, the form
So I am having a few problems with settings this up. Let me explain.
Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
Consider the following base code: (function($) { $.fn.myPlugin = function(settings) { return this.each(function() {
I have this code for the settings: Dim settings As XmlWriterSettings = New XmlWriterSettings()
I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.