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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:02+00:00 2026-05-26T15:57:02+00:00

urlpatterns = patterns(”, # Examples: url(r’^$’, ‘core.views.homepage’, name=’homepage’), url(r’^static/(?P<path>.*)$’, ‘django.views.static.serve’, {‘document_root’: settings.STATIC_ROOT}), ) That’s

  • 0
urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'core.views.homepage', name='homepage'),
    url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)

That’s my urls.py

The static file works if I disable the DEBUG, and doesn’t work If I turn it back on.

Part of my settings

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (

    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

Really strange to me, can anyone help?

  • 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-26T15:57:02+00:00Added an answer on May 26, 2026 at 3:57 pm

    No, STATIC_ROOT is not served by Django ever. In production (debug off), it is expected that your web server will serve this directory directly. In development (debug on), you shouldn’t have this directory or anything in it, anyways.

    Let me say that again for emphasis. You are never supposed to directly save any assets in STATIC_ROOT. This directory is solely for the output from the collectstatic management command. All assets in your project are supposed to be saved in the static directory of the particular app it belongs to.

    Now, of course, you’ll often have assets that are not directly related to a single app, but rather your entire project as a whole. For this scenario, you create a separate directory in your project and place all common assets there. You then add this directory to the STATICFILES_DIRS setting.

    In development, Django will serve anything in that directory, and in production, the collectstatic management command will pull assets from that directory into STATIC_ROOT.

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

Sidebar

Related Questions

I have in my url patterns, urlpatterns += patterns('', (r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/tipu/Dropbox/dev/workspace/search/images'}) In
I have following settings URL urlpatterns = patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), url(r'^index/$','pMass.views.index', name='index'),
# urls.py site_media = os.path.join(os.path.dirname(__file__), 'site_media' ) urlpatterns = patterns('', (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': site_media}),
So, here is one of my urls.py urlpatterns = patterns('items.views', url(r'^(?P<item_id>[\d+])/$', 'view_listing', name=item_view), )
I have the following urlconf: urlpatterns = patterns('page.manager.views', url(r'^$', 'pages', name='page_manager-pages'), url(r'^add/$', 'add_page', name='page_manager-add_page'),
I have an url with an optionnal argument: urlpatterns = patterns( 'my_app.views', url('schedule/(?P<calendar_id>\d+)/(?:month(?P<relative_month>[\+,\-]\d)/)$', 'attribute_event',name='attribute_event')
In one application's urls.py I have: urlpatterns = patterns('app.views', url(r'^products/$', products, name=products), url(r'^$', index,
I have a urlpatterns like this: urlpatterns = patterns('', ... (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict, 'poll_detail'),
These is my django URLconf: urlpatterns = patterns('', ('^hello/$', hello), (r'^polls/$', 'mysite.polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
can i substitute the 2 url routes urlpatterns = patterns('', url(r'service/geticons', 'core.service.geticons'), url(r'service/getnearby', 'core.service.getnearby'),

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.