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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:58:03+00:00 2026-06-11T15:58:03+00:00

In my django app ,I have put these settings settings.py ———— MEDIA_ROOT = ‘/home/me/dev/python/django/myproject/myapp/media/’

  • 0

In my django app ,I have put these settings

settings.py
------------
MEDIA_ROOT = '/home/me/dev/python/django/myproject/myapp/media/'
MEDIA_URL = '/site_media/'

urls.py
--------
...
url(r'^myapp/', include('myapp.urls')),
url(r'^site_media/(?P<path>.*)$','django.views.static.serve',{'document_root':settings.MEDIA_ROOT}),

I created a css file in '/home/me/dev/python/django/myproject/myapp/media/css' folder and included this in template as below

base.html
--------
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>my app</title>
<LINK REL=StyleSheet HREF="{{MEDIA_URL}}css/myappstyle.css" TYPE="text/css" MEDIA="screen, print"/>

home.html
---------
{% extends "mywebapp/base.html" %}>
{% block title %}{{block.super}}| Home {% endblock %}

{% block content %}
   {{block.super}}
   hi
{% endblock %}

Then I created a view as below

def custom_render(request,context,template):
    req_context=RequestContext(request,context)
    return render_to_response(template,req_context)

def home(request,template_name,page_title):
    print 'home'
    return render_to_response(template_name,{'me':'myname'})

and set its url conf

myapp.urls
--------

urlpatterns=patterns('',
  url(r'^$','myapp.views.home',
      {
         'template_name':'mywebapp/home.html',
         'page_title':'Home'
       },
      name='home'),

when I give the url

http://127.0.0.1:8000/myapp/

The web page gets rendered ,but css is not.The console output shows a 404 error

[14/Sep/2012 10:02:50] "GET /myapp/ HTTP/1.1" 200 547
[14/Sep/2012 10:02:50] "GET /myapp/css/myappstyle.css HTTP/1.1" 404 2514

But,when I give the url,

http://127.0.0.1:8000/site_media/css/myappstyle.css

I can see the contents of the css file without any problems.

Why does this happen? can someone help me figure this out?

  • 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-11T15:58:05+00:00Added an answer on June 11, 2026 at 3:58 pm

    You need to use RequestContext() while rendering response for home view also (as you have done for custom_render view).

    Otherwise {{MEDIA_URL}} will be empty which will result in 404 error.

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

Sidebar

Related Questions

I have a Django app written in Python 2.5 and I plan to upgrade
In my django app, I have these models class Lesson(models.Model): name = models.CharField(max_length=200) course
I have a Django app that gets it's data completely from an external source
I have a Django app that use a django-tagging. I need to port this
I have a Django app where most of the search is driven by foreign
I have a django app with models as follows: A Question model An Answer
I have a django app that I made and have implemented a plist into
I have a Django app and I am trying to perform transactions over multiple
I have a django app which is used for managing registrations to a survey.
I have a Django app where multiple teams upload content that will be parsed.

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.