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 7630465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:06:36+00:00 2026-05-31T06:06:36+00:00

When I use MEDIA_URL or STATIC_URL to point to /static/ currently set MEDIA_URL to

  • 0

When I use MEDIA_URL or STATIC_URL to point to /static/ currently set MEDIA_URL to /static/
and using it in a path to CSS file like:

<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/css.css" />

It points to /static/css.css, but trying http://localhost/static/css.css gives 404 error.

I have in settings:

.....
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/static/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = 'D:/programming/django_projects/ecomstore/'
.....

In urls.py I have point to static like this:

url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
     {'document_root':'D:/programming/django_projects/ecomstore/'}

So where problem is? Why it is showing 404, do I need to create some view for static files? Or is there some thing else wrong in my settings or urls.py ? Any response will be appreciated, as I am newbie in django.

thanks in advance

  • 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-05-31T06:06:38+00:00Added an answer on May 31, 2026 at 6:06 am

    You need to re-read the docs more closely: https://docs.djangoproject.com/en/dev/howto/static-files/

    Here’s some things to note:

    1. MEDIA_URL and MEDIA_ROOT are for user uploads (FileFields and ImageFields on your models). It should be its own folder; “media” is common.

    2. STATIC_URL and STATIC_ROOT are for your static resources. It should also be its own folder; “static” is common.

    3. Do not actually put anything in STATIC_ROOT. This directory is only for the output of the collectstatic management command in production.

    4. Your static resources should go in your apps’ “static” folder or a completely new and different directory (i.e. not MEDIA_ROOT or STATIC_ROOT). You then add the path to that directory to STATICFILES_DIRS.

    5. Don’t add anything to urls.py. In development, Django will automatically serve anything in your apps “static” directories or any directory in STATICFILES_DIRS. In production, your webserver will be responsible for serving these files.

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

Sidebar

Related Questions

I would like to serve static plist files using mod_wsgi . In have configured
I have something like: MEDIA_ROOT = '/home/httpd/foo/media/' MEDIA_URL = 'http://www.example.org/media/' (...) file = models.FileField(upload_to='test')
http://docs.djangoproject.com/en/dev/howto/static-files/ This suggests that I can use STATIC_URL in my template to get the
When using django, compressor, and clevercss, I set my css url to an absolute
I use media queries on a page http://test.lovecpokladu.cz/detail-mince?id=2461 like this: @media all and (min-width:
Java Message Service book by O'Reilly Media says: use request/reply model in point-to-point messaging.
I use below code to get photo's path and id: String[] projection = {MediaStore.Images.Media._ID,
use C#,want to upload excel file on google doc. bellow syntax use to upload
I've been using this little snippet to select random images. However I would like
Am working with django 1.3 and doing some template inheritance. My /static/ settings path

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.