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

  • Home
  • SEARCH
  • 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 8271183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:46:43+00:00 2026-06-08T06:46:43+00:00

I am trying to let external css files work on the django 1.3 development

  • 0

I am trying to let external css files work on the django 1.3 development server. I read the django’s ‘managing static files’ as well as numerous similar SO questions but I still seem to do something wrong.

Why isn’t my css style properly showing when I go to localhost:8000/page?

Directory structure

myproject
|-- manage.py
|-- settings.py
|-- urls.py
|-- app
    |-- __init__.py
    |-- models.py
    |-- tests.py
    |-- views.py
    |-- static
        |-- css
            |-- page.css
|-- templates
    |-- app
        |-- page.html

myproject/views.py

import django.http
import django.template.loader
import django.template  

def page_function(request):
    t = django.template.loader.get_template("page.html")
    c = django.template.Context()
    return django.http.HttpResponse(t.render(c))

myproject/urls.py

from django.conf.urls.defaults import patterns, include, url
import myproject.app.views

urlpatterns = patterns('',(r'page/$', myproject.app.views.page_function),)

myproject/templates/app/page.css

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}page.css" />
</head>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html> 

myproject/settings.py

(partially)

MEDIA_ROOT = ''

MEDIA_URL = ''

STATIC_ROOT = ''

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    "/home/myusername/Desktop/myproject/app/static",
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

ROOT_URLCONF = 'myproject.urls'

TEMPLATE_DIRS = (
    '/home/myusername/Desktop/myproject/templates/app', 
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app'
)
  • 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-08T06:46:44+00:00Added an answer on June 8, 2026 at 6:46 am

    From the django docs:

    If {{ STATIC_URL }} isn’t working in your template, you’re probably
    not using RequestContext when rendering the template.

    As a brief refresher, context processors add variables into the
    contexts of every template. However, context processors require that
    you use RequestContext when rendering templates. This happens
    automatically if you’re using a generic view, but in views written by
    hand you’ll need to explicitly use RequestContext To see how that
    works, and to read more details, check out Subclassing Context:
    RequestContext.

    Another option is the get_static_prefix template tag that is part of
    Django’s core.

    Instead of

    {{ STATIC_URL }}page.css
    

    You’ll want to use:

    {% load static %}
    {% get_static_prefix %}css/page.css
    

    Also note that the directory structure is maintained with static files, so because your page.css is in a subdirectory of ‘static’, you’ll need to load it in the template as ‘css/page.css’.

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

Sidebar

Related Questions

I'm trying to let users type in date and time values into an input
I am trying to let GoogleBot login to my website and bypass the authentication.
I'm trying to let a user "make his own service". most direct method I
Hi Guys i'm trying to let my Screen blink a morse code out using
I am using the jQuery Datepicker( http://keith-wood.name/datepick.html ). I am trying to let the
I've got this odd problem with jQuery. I'm trying to let the change of
What I'm trying to achieve is: Let inflector slug Ignore a special character in
Let me first explain what's I'm trying to do. So I have a entity
Trying to avoid the SomethingManager trap here... Let's say I'm going to write a
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]

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.