2013-11-20 4 views
3

내 프로젝트의 이름은 homefood이고 서버를 실행할 때이 오류가 발생합니다.이 오류를 해결하는 방법에 대한 단서가 있습니다.장고 404 오류 페이지를 찾을 수 없습니다.

Page not found (404) 

Request Method: GET 

Request URL: http://127.0.0.1:8000/ 

Using the URLconf defined in homefood.urls, Django tried these URL patterns, in this order: 

^foodPosts/ 

^admin/ 

The current URL, , didn't match any of these. 

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. 
내 settings.py 파일은 다음과 같습니다

...

import dj_database_url 
""" 
Django settings for homefood project. 

# Build paths inside the project like this: os.path.join(BASE_DIR, ...) 
import os 
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 
STATIC_ROOT = 'staticfiles' 


# SECURITY WARNING: keep the secret key used in production secret! 


# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = True 

TEMPLATE_DIRS = (

    os.path.join(BASE_DIR, 'templates'), 
) 


TEMPLATE_DEBUG = True 

ALLOWED_HOSTS = ['*']  # Allow all host headers 


# Application definition 

INSTALLED_APPS = (
'django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.humanize', 
'django.contrib.sites', 
'foodPosts', 
'registration', 
'profiles', 
'homefood', 

) 

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.clickjacking.XFrameOptionsMiddleware', 
) 

ROOT_URLCONF = 'homefood.urls' 

WSGI_APPLICATION = 'homefood.wsgi.application' 



#= dj_database_url.config() 
#'default': dj_database_url.config(default='mysql://localhost')} 
DATABASES = { 
'default': { 
    'ENGINE': 'django.db.backends.mysql', 
    'NAME': 'django_db', 
    'USER': 'root', 
    'PASSWORD': '', 
    'HOST': '', 
    'PORT': '', 
} 
}#= dj_database_url.config() 

# Honor the 'X-Forwarded-Proto' header for request.is_secure() 
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') 

LANGUAGE_CODE = 'en-us' 

TIME_ZONE = 'America/New_York' 

USE_I18N = True 

USE_L10N = True 

USE_TZ = True 

#Django-registration additions, for account registration 
ACCOUNT_ACTIVATION_DAYS=7 
EMAIL_HOST = 'localhost' 
EMAIL_PORT = 102 
EMAIL_HOST_USERNAME = '' 
EMAIL_HOST_PASSWORD = '' 
EMAIL_USE_TLS = False 
DEFAULT_FROM_EMAIL = '[email protected]' 

STATIC_URL = '/static/' 


STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'), 

)           #static asset configuration 

내 homefood 폴더에 내 urls.py는

from django.conf.urls import patterns, include, url 




from django.contrib import admin 
admin.autodiscover() 

urlpatterns = patterns('', 
    # Examples: 
    # url(r'^$', 'homefood.views.home', name='home'), 
    # url(r'^blog/', include('blog.urls')), 


    url(r'^foodPosts/',include('foodPosts.urls')), 
    url(r'^admin/', include(admin.site.urls)), 


) 

나는 내 문제 중 하나로 생각하는 내 urls.py 또는 내 settings.py하지만 확실하지 않습니다. 어떤 도움이라도 대단히 감사하겠습니다. 감사.

답변

15

아직 http://127.0.0.1:8000/에 대한 URL 패턴을 정의하지 않았기 때문에 404가 표시됩니다.

관리자 사이트는 http://127.0.0.1:8000/admin/이고 음식 게시글은 http://127.0.0.1:8000/foodPosts/입니다.

홈페이지에 대한 URL 패턴을 추가하려면 urls.py에서 다음 항목의 주석 처리를 제거하고 homefood.views.home을 사용하려는보기의 경로로 바꿉니다.

url(r'^$', 'homefood.views.home', name='home'), 
관련 문제