OK. # Django settings for final project.
DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_em...@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写道: > > Could you please add your setting.py from root of the your project to > your letter ? > > 2012/4/3 Homer <hi...@foxmail.com>: > > 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写道: > >> > >> 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/ > >> > >> > >> 2012/4/3 Homer <hi...@foxmail.com>: > >> > 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写道: > >> >> > >> >> please post section of the setting.py file > >> >> > >> >> TEMPLATE_CONTEXT_PROCESSORS > >> >> > >> >> Has this file > >> >> > >> >> 'django.core.context_processors.static', > >> >> > >> >> 2012/4/3 Homer <hi...@foxmail.com>: > >> >> > I think "media_root" works well since I also used pictures on my > >> >> > another > >> >> > page. Maybe there is something wrong in my urlconf... > >> >> > > >> >> > 在 2012年4月2日星期一UTC-4下午8时41分02秒,St@n写道: > >> >> >> > >> >> >> check your Media_root in settings.py. > >> >> >> > >> >> >> It could be a missing stroke. > >> >> >> > >> >> >> Best Regards, > >> >> >> > >> >> >> Stanwin Siow > >> >> >> > >> >> >> > >> >> >> > >> >> >> On Apr 3, 2012, at 8:14 AM, Homer wrote: > >> >> >> > >> >> >> 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-users@googlegroups.com. > >> >> >> To unsubscribe from this group, send email to > >> >> >> django-users+unsubscr...@googlegroups.com. > >> >> >> 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-users@googlegroups.com > . > >> >> > To unsubscribe from this group, send email to > >> >> > django-users+unsubscr...@googlegroups.com. > >> >> > 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-users@googlegroups.com. > >> > To unsubscribe from this group, send email to > >> > django-users+unsubscr...@googlegroups.com. > >> > 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-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.