473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Django: 404 page not found

11
I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom . It says on the webpage that "C:/Django/final/media/bedroom" does not exist". Why would this happen?

urls.py:
Expand|Select|Wrap|Line Numbers
  1. from django.conf.urls.defaults import *
  2. from final import settings
  3.  
  4. from django.contrib import admin
  5.  
  6. admin.autodiscover()
  7.  
  8. urlpatterns = patterns('',
  9.  
  10.     url(r'^admin/', include(admin.site.urls)),
  11.  
  12.     url(r'^cn/', include('final.photo.urls')),
  13.  
  14.     url(r'^cn/(?P<path>.*)$', 'django.views.static.serve',
  15.  
  16.         {'document_root': settings.MEDIA_ROOT}),
  17.  
  18. )
photo/urls.py:
Expand|Select|Wrap|Line Numbers
  1. from django.conf.urls.defaults import *
  2.  
  3. from final.photo.views import List, Detail
  4.  
  5. urlpatterns = patterns('',
  6.  
  7.     url(r'^$', List),
  8.     url(r'^/bedroom/', Detail),
  9.  
  10. )
  11.  
photo/views.py:
Expand|Select|Wrap|Line Numbers
  1. # Create your views here.
  2.  
  3. from django.template import loader, Context, RequestContext
  4.  
  5. from django.http import HttpResponse
  6.  
  7. from final.photo.models import Image, Audio, Pinyin, SImage
  8.  
  9. from django.shortcuts import render_to_response
  10.  
  11. def List(request):
  12.  
  13.     ShowSImage = SImage.objects.all()
  14.     ShowLink = Image.objects.all()
  15.  
  16.     context = RequestContext(request, {
  17.  
  18.          'ShowSImage': ShowSImage, 'ShowLink': ShowLink
  19.  
  20.     })
  21.  
  22.     return render_to_response('list.html', context)
  23.  
  24. def Detail(request):
  25.     ShowImage = Image.objects.all()
  26.     ShowPinyin = Pinyin.objects.all()
  27.     ShowAudio = Audio.objects.all()
  28.     context = RequestContext(request, {
  29.         'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin': ShowPinyin
  30.     })
  31.     return render_to_response('detail.html', context)
detail.html:
Expand|Select|Wrap|Line Numbers
  1. {% extends "base.html" %}
  2.  
  3. {% block title %}{{ item.title }}{% endblock %}
  4.  
  5. {% block content %}
  6.  
  7. <h2>{{ item.title }}</h2>
  8. <img src="{{ item.get_image_url }}" />
  9. {% if object.caption %}<p>{{ object.caption }}</p>{% endif %}
  10.  
  11. {% endblock %}
Thanks in advance!
Apr 2 '12 #1
0 1410

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philip Herlihy | last post by:
I get more JS errors than I'd expect, on a wide range of sites. (It's possible I only know this because the Debug is set on). I found an error on a Microsoft site, and decided to investigate. I...
2
by: Applepieandpeas | last post by:
Hi, I am doing a course in web-design, and while trying things out (making a page), found that it is not valid. The message I got back said that it cannot recognise it because it must be text/html....
28
by: flamesrock | last post by:
Firstly, this topic is NOT intended for trolling or starting any flame wars. I want to know if anyone has experience with these frameworks, and if so, how do they compare? Which one do you...
3
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
13
by: Ilias Lazaridis | last post by:
I have implemented a simple schema evolution support for django, due to a need for a personal project. Additionally, I've provided an Audit: http://case.lazaridis.com/wiki/DjangoAudit As a...
1
by: kernel1983 | last post by:
I look it up in PyPI There are info about Django: Package Score Description Django096 0.96 6 Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic...
0
by: kang jia | last post by:
hi i am currently learning Django framework and i have to do a login page at the moment. i have used the code like following: from django.contrib.auth import authenticate, login def...
0
by: kang jia | last post by:
hi i have small problems occurred in my login function, which i use Django to build, in my template which is login.html, the code is like the following: <html> <head>...
12
by: Dave U. Random | last post by:
http://snipr.com/PracticalDjango
4
by: K | last post by:
Hello everyone, I understand that urllib and urllib2 serve as really simple page request libraries. I was wondering if there is a library out there that can get the HTTP requests for a given...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.