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: - from django.conf.urls.defaults import *
-
from final import settings
-
-
from django.contrib import admin
-
-
admin.autodiscover()
-
-
urlpatterns = patterns('',
-
-
url(r'^admin/', include(admin.site.urls)),
-
-
url(r'^cn/', include('final.photo.urls')),
-
-
url(r'^cn/(?P<path>.*)$', 'django.views.static.serve',
-
-
{'document_root': settings.MEDIA_ROOT}),
-
-
)
photo/urls.py: - from django.conf.urls.defaults import *
-
-
from final.photo.views import List, Detail
-
-
urlpatterns = patterns('',
-
-
url(r'^$', List),
-
url(r'^/bedroom/', Detail),
-
-
)
-
photo/views.py: - # Create your views here.
-
-
from django.template import loader, Context, RequestContext
-
-
from django.http import HttpResponse
-
-
from final.photo.models import Image, Audio, Pinyin, SImage
-
-
from django.shortcuts import render_to_response
-
-
def List(request):
-
-
ShowSImage = SImage.objects.all()
-
ShowLink = Image.objects.all()
-
-
context = RequestContext(request, {
-
-
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
-
-
})
-
-
return render_to_response('list.html', context)
-
-
def Detail(request):
-
ShowImage = Image.objects.all()
-
ShowPinyin = Pinyin.objects.all()
-
ShowAudio = Audio.objects.all()
-
context = RequestContext(request, {
-
'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin': ShowPinyin
-
})
-
return render_to_response('detail.html', context)
detail.html: - {% extends "base.html" %}
-
-
{% block title %}{{ item.title }}{% endblock %}
-
-
{% block content %}
-
-
<h2>{{ item.title }}</h2>
-
<img src="{{ item.get_image_url }}" />
-
{% if object.caption %}<p>{{ object.caption }}</p>{% endif %}
-
-
{% endblock %}
Thanks in advance!
0 1410 Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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>...
|
by: Dave U. Random |
last post by:
http://snipr.com/PracticalDjango
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |