Discussion:
Django: 404 page not found
Homer
2012-04-03 00:14:00 UTC
Permalink
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:*


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!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Stanwin Siow
2012-04-03 00:41:02 UTC
Permalink
check your Media_root in settings.py.

It could be a missing stroke.

Best Regards,

Stanwin Siow
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
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)
{% 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!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 01:20:21 UTC
Permalink
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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:*
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Sergiy Khohlov
2012-04-03 06:20:30 UTC
Permalink
please post section of the setting.py file

TEMPLATE_CONTEXT_PROCESSORS

Has this file

'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
    url(r'^$', List),
    url(r'^/bedroom/', Detail),
)
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
    ShowSImage = SImage.objects.all()
    ShowLink = Image.objects.all()
    context = RequestContext(request, {
         'ShowSImage': ShowSImage, 'ShowLink': ShowLink
    })
    return render_to_response('list.html', context)
    ShowImage = Image.objects.all()
    ShowPinyin = Pinyin.objects.all()
    ShowAudio = Audio.objects.all()
    context = RequestContext(request, {
ShowPinyin
    })
    return render_to_response('detail.html', context)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 12:53:34 UTC
Permalink
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I do
not know whether it is related to the version of Django. I am using Django
1.3 right now.

ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç2ʱ20·Ö30Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
I met "404" page not found when I try to enter
127.0.0.1:8000/cn/bedroom .
Post by Homer
Post by Stanwin Siow
It says on the webpage that "C:/Django/final/media/bedroom" does not
exist".
Post by Homer
Post by Stanwin Siow
Why would this happen?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
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)
{% 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!
--
You received this message because you are subscribed to the Google
Groups
Post by Homer
Post by Stanwin Siow
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Ivo Marcelo Leonardi Zaniolo
2012-04-03 12:56:07 UTC
Permalink
You can add that var on settings.py.
*
Ivo Marcelo Leonardi Zaniolo*
*imarcelolz.blogspot.com.br*
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I
do not know whether it is related to the version of Django. I am using
Django 1.3 right now.
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç2ʱ20·Ö30Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_**processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
I met "404" page not found when I try to enter
127.0.0.1:8000/cn/bedroom .
Post by Homer
Post by Stanwin Siow
It says on the webpage that "C:/Django/final/media/**bedroom" does
not exist".
Post by Homer
Post by Stanwin Siow
Why would this happen?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html'**, context)
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)
{% 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!
--
You received this message because you are subscribed to the Google
Groups
Post by Homer
Post by Stanwin Siow
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/**msg/django-users/-/**V1uKDrAvYS0J<https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J>
.
Post by Homer
Post by Stanwin Siow
To unsubscribe from this group, send email to
.
Post by Homer
Post by Stanwin Siow
For more options, visit this group at
http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
.
Post by Homer
--
You received this message because you are subscribed to the Google
Groups
Post by Homer
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/**msg/django-users/-/**Os90mGtKgrIJ<https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ>
.
Post by Homer
To unsubscribe from this group, send email to
.
Post by Homer
For more options, visit this group at
http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Sergiy Khohlov
2012-04-03 12:57:57 UTC
Permalink
this section from my last project :


TEMPLATE_CONTEXT_PROCESSORS = (

'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)

You have problem without 'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I do
not know whether it is related to the version of Django. I am using Django
1.3 right now.
在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
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)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 13:49:26 UTC
Permalink
I add the section you provided to my settings.py but it still does not
work...

ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç8ʱ57·Ö57Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)
You have problem without 'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I
do
Post by Homer
not know whether it is related to the version of Django. I am using
Django
Post by Homer
1.3 right now.
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç2ʱ20·Ö30Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my
another
Post by Homer
Post by Sergiy Khohlov
Post by Homer
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
ShowImage = Image.objects.all()
ShowPinyin = Pinyin.objects.all()
ShowAudio = Audio.objects.all()
context = RequestContext(request, {
ShowPinyin
})
return render_to_response('detail.html', context)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VqmbjpUWJpMJ.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Sergiy Khohlov
2012-04-03 13:58:54 UTC
Permalink
Could you please add your setting.py from root of the your project to
your letter ?
Post by Homer
I add the section you provided to my settings.py but it still does not
work...
在 2012年4月3日星期二UTC-4上午8时57分57秒,skhohlov写道:
Post by Sergiy Khohlov
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)
You have problem without 'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I do
not know whether it is related to the version of Django. I am using Django
1.3 right now.
在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
ShowImage = Image.objects.all()
ShowPinyin = Pinyin.objects.all()
ShowAudio = Audio.objects.all()
context = RequestContext(request, {
'ShowAudio': ShowAudio, 'ShowImage': ShowImage,
ShowPinyin
})
return render_to_response('detail.html', context)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/VqmbjpUWJpMJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 17:23:53 UTC
Permalink
OK.
# Django settings for final project.



DEBUG = True

TEMPLATE_DEBUG = DEBUG



ADMINS = (

# ('Your Name', '***@example.com'),

)



MANAGERS = ADMINS



DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

'NAME': 'C:/Django/final/data.db', # Or path
to database file if using sqlite3.

'USER': '', # Not used with sqlite3.

'PASSWORD': '', # Not used with sqlite3.

'HOST': '', # Set to empty string for
localhost. Not used with sqlite3.

'PORT': '', # Set to empty string for default.
Not used with sqlite3.

}

}



# Local time zone for this installation. Choices can be found here:

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

# although not all choices may be available on all operating systems.

# On Unix systems, a value of None will cause Django to use the same

# timezone as the operating system.

# If running in a Windows environment this must be set to the same as your

# system time zone.

TIME_ZONE = 'America/Chicago'



# Language code for this installation. All choices can be found here:

# http://www.i18nguy.com/unicode/language-identifiers.html

LANGUAGE_CODE = 'en-us'



SITE_ID = 1



# If you set this to False, Django will make some optimizations so as not

# to load the internationalization machinery.

USE_I18N = True



# If you set this to False, Django will not format dates, numbers and

# calendars according to the current locale

USE_L10N = True



# Absolute filesystem path to the directory that will hold user-uploaded
files.

# Example: "/home/media/media.lawrence.com/media/"

MEDIA_ROOT = 'C:/Django/final/media/'



# URL that handles the media served from MEDIA_ROOT. Make sure to use a

# trailing slash.

# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"

MEDIA_URL = '/media/'



# Absolute path to the directory static files should be collected to.

# Don't put anything in this directory yourself; store your static files

# in apps' "static/" subdirectories and in STATICFILES_DIRS.

# Example: "/home/media/media.lawrence.com/static/"

STATIC_ROOT = ''



# 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',

)



# Make this unique, and don't share it with anybody.

SECRET_KEY = 'zg*^7-e5e(#wu6-543z0y#em+xvjo092h^%@*&qed^hqqa!2i5'



# List of callables that know how to import templates from various sources.

TEMPLATE_LOADERS = (

'django.template.loaders.filesystem.Loader',

'django.template.loaders.app_directories.Loader',

# 'django.template.loaders.eggs.Loader',

)



MIDDLEWARE_CLASSES = (

'django.middleware.common.CommonMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

)



ROOT_URLCONF = 'final.urls'



TEMPLATE_DIRS = ("C:/Django/final/photo/templates"

# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



INSTALLED_APPS = (

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.sites',

'django.contrib.messages',

'django.contrib.staticfiles',

# Uncomment the next line to enable the admin:

'django.contrib.admin',

'final.photo',

# Uncomment the next line to enable admin documentation:

# 'django.contrib.admindocs',

)



# A sample logging configuration. The only tangible logging

# performed by this configuration is to send an email to

# the site admins on every HTTP 500 error.

# See http://docs.djangoproject.com/en/dev/topics/logging for

# more details on how to customize your logging configuration.

LOGGING = {

'version': 1,

'disable_existing_loggers': False,

'handlers': {

'mail_admins': {

'level': 'ERROR',

'class': 'django.utils.log.AdminEmailHandler'

}

},

'loggers': {

'django.request': {

'handlers': ['mail_admins'],

'level': 'ERROR',

'propagate': True,

},

}

}

TEMPLATE_CONTEXT_PROCESSORS = (

'django.core.context_processors.request',

'django.core.context_processors.debug',

'django.core.context_processors.i18n',

'django.core.context_processors.media',

'django.core.context_processors.static',

'django.contrib.auth.context_processors.auth',

'django.contrib.messages.context_processors.messages',

)

ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç9ʱ58·Ö54Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
Could you please add your setting.py from root of the your project to
your letter ?
Post by Homer
I add the section you provided to my settings.py but it still does not
work...
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç8ʱ57·Ö57Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)
You have problem without 'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my
settings.py. I
Post by Homer
Post by Sergiy Khohlov
Post by Homer
do
not know whether it is related to the version of Django. I am using Django
1.3 right now.
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç2ʱ20·Ö30Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Stanwin Siow
exist".
Why would this happen?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
ShowImage = Image.objects.all()
ShowPinyin = Pinyin.objects.all()
ShowAudio = Audio.objects.all()
context = RequestContext(request, {
ShowPinyin
})
return render_to_response('detail.html', context)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
.
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Sergiy Khohlov
Post by Homer
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/VqmbjpUWJpMJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NJ36nbAJH2cJ.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 17:23:50 UTC
Permalink
OK.
# Django settings for final project.



DEBUG = True

TEMPLATE_DEBUG = DEBUG



ADMINS = (

# ('Your Name', '***@example.com'),

)



MANAGERS = ADMINS



DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

'NAME': 'C:/Django/final/data.db', # Or path
to database file if using sqlite3.

'USER': '', # Not used with sqlite3.

'PASSWORD': '', # Not used with sqlite3.

'HOST': '', # Set to empty string for
localhost. Not used with sqlite3.

'PORT': '', # Set to empty string for default.
Not used with sqlite3.

}

}



# Local time zone for this installation. Choices can be found here:

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

# although not all choices may be available on all operating systems.

# On Unix systems, a value of None will cause Django to use the same

# timezone as the operating system.

# If running in a Windows environment this must be set to the same as your

# system time zone.

TIME_ZONE = 'America/Chicago'



# Language code for this installation. All choices can be found here:

# http://www.i18nguy.com/unicode/language-identifiers.html

LANGUAGE_CODE = 'en-us'



SITE_ID = 1



# If you set this to False, Django will make some optimizations so as not

# to load the internationalization machinery.

USE_I18N = True



# If you set this to False, Django will not format dates, numbers and

# calendars according to the current locale

USE_L10N = True



# Absolute filesystem path to the directory that will hold user-uploaded
files.

# Example: "/home/media/media.lawrence.com/media/"

MEDIA_ROOT = 'C:/Django/final/media/'



# URL that handles the media served from MEDIA_ROOT. Make sure to use a

# trailing slash.

# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"

MEDIA_URL = '/media/'



# Absolute path to the directory static files should be collected to.

# Don't put anything in this directory yourself; store your static files

# in apps' "static/" subdirectories and in STATICFILES_DIRS.

# Example: "/home/media/media.lawrence.com/static/"

STATIC_ROOT = ''



# 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',

)



# Make this unique, and don't share it with anybody.

SECRET_KEY = 'zg*^7-e5e(#wu6-543z0y#em+xvjo092h^%@*&qed^hqqa!2i5'



# List of callables that know how to import templates from various sources.

TEMPLATE_LOADERS = (

'django.template.loaders.filesystem.Loader',

'django.template.loaders.app_directories.Loader',

# 'django.template.loaders.eggs.Loader',

)



MIDDLEWARE_CLASSES = (

'django.middleware.common.CommonMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

)



ROOT_URLCONF = 'final.urls'



TEMPLATE_DIRS = ("C:/Django/final/photo/templates"

# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



INSTALLED_APPS = (

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.sites',

'django.contrib.messages',

'django.contrib.staticfiles',

# Uncomment the next line to enable the admin:

'django.contrib.admin',

'final.photo',

# Uncomment the next line to enable admin documentation:

# 'django.contrib.admindocs',

)



# A sample logging configuration. The only tangible logging

# performed by this configuration is to send an email to

# the site admins on every HTTP 500 error.

# See http://docs.djangoproject.com/en/dev/topics/logging for

# more details on how to customize your logging configuration.

LOGGING = {

'version': 1,

'disable_existing_loggers': False,

'handlers': {

'mail_admins': {

'level': 'ERROR',

'class': 'django.utils.log.AdminEmailHandler'

}

},

'loggers': {

'django.request': {

'handlers': ['mail_admins'],

'level': 'ERROR',

'propagate': True,

},

}

}

TEMPLATE_CONTEXT_PROCESSORS = (

'django.core.context_processors.request',

'django.core.context_processors.debug',

'django.core.context_processors.i18n',

'django.core.context_processors.media',

'django.core.context_processors.static',

'django.contrib.auth.context_processors.auth',

'django.contrib.messages.context_processors.messages',

)

ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç9ʱ58·Ö54Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
Could you please add your setting.py from root of the your project to
your letter ?
Post by Homer
I add the section you provided to my settings.py but it still does not
work...
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç8ʱ57·Ö57Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)
You have problem without 'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/
Post by Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my
settings.py. I
Post by Homer
Post by Sergiy Khohlov
Post by Homer
do
not know whether it is related to the version of Django. I am using Django
1.3 right now.
ÔÚ 2012Äê4ÔÂ3ÈÕÐÇÆÚ¶þUTC-4ÉÏÎç2ʱ20·Ö30Ã룬skhohlovÐŽµÀ£º
Post by Sergiy Khohlov
please post section of the setting.py file
TEMPLATE_CONTEXT_PROCESSORS
Has this file
'django.core.context_processors.static',
Post by Homer
I think "media_root" works well since I also used pictures on my another
page. Maybe there is something wrong in my urlconf...
Post by Stanwin Siow
check your Media_root in settings.py.
It could be a missing stroke.
Best Regards,
Stanwin Siow
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
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Stanwin Siow
exist".
Why would this happen?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
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
ShowSImage = SImage.objects.all()
ShowLink = Image.objects.all()
context = RequestContext(request, {
'ShowSImage': ShowSImage, 'ShowLink': ShowLink
})
return render_to_response('list.html', context)
ShowImage = Image.objects.all()
ShowPinyin = Pinyin.objects.all()
ShowAudio = Audio.objects.all()
context = RequestContext(request, {
ShowPinyin
})
return render_to_response('detail.html', context)
{% 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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
.
Post by Homer
Post by Sergiy Khohlov
Post by Homer
Post by Sergiy Khohlov
Post by Homer
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/VqmbjpUWJpMJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-RURjbhzQg8J.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Tom Evans
2012-04-03 14:09:11 UTC
Permalink
Post by Homer
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?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
    url(r'^$', List),
    url(r'^/bedroom/', Detail),
)
You have conflicting URL space, you have configured "^cn/" to be both
where your static files are served from, and also where your views are
served from. Split the two up, and use the correct URL, and you should
not have any problems. Eg:

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^photos/', include('final.photo.urls')),
    url(r'^docs/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
)

I'm not sure why people are interested in your
TEMPLATE_CONTEXT_PROCESSORS settings when the request isn't even
making it to the view...

Cheers

Tom
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 17:30:55 UTC
Permalink
If I split them up, I cannot see my pictures on the webpage since the links
of them becomes "Loading Image...". But my pictures
stored in "Loading Image..."... That's why I mix
them up...

圚 2012幎4月3日星期二UTC-4䞊午10时09分11秒Tom Evans写道
Post by Homer
Post by Stanwin Siow
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".
Post by Stanwin Siow
Why would this happen?
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}),
)
from django.conf.urls.defaults import *
from final.photo.views import List, Detail
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
You have conflicting URL space, you have configured "^cn/" to be both
where your static files are served from, and also where your views are
served from. Split the two up, and use the correct URL, and you should
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^photos/', include('final.photo.urls')),
url(r'^docs/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
I'm not sure why people are interested in your
TEMPLATE_CONTEXT_PROCESSORS settings when the request isn't even
making it to the view...
Cheers
Tom
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/B5lBiyNWrI4J.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Sebastian Goll
2012-04-03 14:17:03 UTC
Permalink
On Mon, 2 Apr 2012 17:14:00 -0700 (PDT)
Post by Homer
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
urlpatterns = patterns('',

url(r'^cn/', include('final.photo.urls')),
url(r'^cn/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
# photo/urls.py
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
Trying to access 'cn/bedroom' _should_ redirect to view Detail, I guess.

But what happens is that 'cn/' gets stripped via the main level pattern,
including 'final.photo.urls'. There no match is found due to the leading
'/' in the second pattern: r'^/bedroom/'. Thus the search continues with
'cn/(?P<path>.*)$' in the top-level URL patterns which tries to access a
non-existing media file in settings.MEDIA_ROOT.

Therefore, to fix the issue, you should remove the leading forward slash
'/' in the second pattern in your photo/urls.py.

For reference, see the notes section in

https://docs.djangoproject.com/en/1.4/topics/http/urls/#example
– "There's no need to add a leading slash, because every URL has that.
For example, it's ^articles, not ^/articles."

Best wishes,
Sebastian.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Homer
2012-04-03 17:41:36 UTC
Permalink
I fixed it by changing the urlconf to r'^bedroom/'. Thanks!!!!!!!!!!

圚 2012幎4月3日星期二UTC-4䞊午10时17分03秒Sebastian写道
Post by Sebastian Goll
On Mon, 2 Apr 2012 17:14:00 -0700 (PDT)
Post by Stanwin Siow
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
urlpatterns = patterns('',


url(r'^cn/', include('final.photo.urls')),
url(r'^cn/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
# photo/urls.py
urlpatterns = patterns('',
url(r'^$', List),
url(r'^/bedroom/', Detail),
)
Trying to access 'cn/bedroom' _should_ redirect to view Detail, I guess.
But what happens is that 'cn/' gets stripped via the main level pattern,
including 'final.photo.urls'. There no match is found due to the leading
'/' in the second pattern: r'^/bedroom/'. Thus the search continues with
'cn/(?P<path>.*)$' in the top-level URL patterns which tries to access a
non-existing media file in settings.MEDIA_ROOT.
Therefore, to fix the issue, you should remove the leading forward slash
'/' in the second pattern in your photo/urls.py.
For reference, see the notes section in
https://docs.djangoproject.com/en/1.4/topics/http/urls/#example
– "There's no need to add a leading slash, because every URL has that.
For example, it's ^articles, not ^/articles."
Best wishes,
Sebastian.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/C7ZtIKebjJ0J.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Continue reading on narkive:
Loading...