부적절한 구성 : 포함 된 urlconf .urls에는 패턴이 없습니다.
dev 서버에서 잘 실행되는 django (1.6.x) 프로젝트가 있지만 Ubuntu 12.04.3에서 Apache2 (2.2.22.1) 및 mod_wsgi (3.3-4)에서 오류가 발생하여 실패합니다.
부적절하게 구성됨 : 포함 된 urlconf erp.urls에 패턴이 없습니다.
Dev 서버에서는 작동하지만 Apache2 / mod_wsgi에서는 작동하지 않는 이유를 이해할 수 없으며 오류가 발생한 위치를 추적하기가 어렵습니다.
유사한 다른 SO 질문이 많이 있지만 reverse (이전에 발견 된 한 가지 문제)를 사용하는 유일한 곳은 내 모델의 get_absolute_url입니다.이게 괜찮을까요?
이 프로젝트는 La Two Scoops 스타일로 설정되며 특히 레이아웃은 다음과 같습니다.
<repository_root>/<django_project_root>/<configuration_root>/
이는 다음과 같이 번역됩니다.
erp_root/erp/erp/
그리고 설정은
erp_root/erp/erp/settings/*py
(포함 __init__.py
)
erp / urls.py;
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
url(r'^admin/', include(admin.site.urls)),
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout_then_login', {}, name='logout'),
url(r'^search/', include('haystack.urls')),
url(r'^inventory/', include('inventory.urls')),
)
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
및 inventory / urls.py :
from django.conf.urls import url, patterns
from .forms import CarrierWizardForm1, CarrierWizardForm2, MovementWizardForm1,MovementWizardForm2
from . import views
carrier_wizard_forms = [CarrierWizardForm1, CarrierWizardForm2]
movement_wizard_forms = [MovementWizardForm1, MovementWizardForm2]
urlpatterns = patterns('',
url(r'^$', views.PartNumberListView.as_view(), name='inventory_list_index'),
url(r'^parttype/$', views.part_type_list, name='index'),
url(r'^parttype/(?P<parttype>\d{2})/$', views.part_type_view, name='part_type_view'),
url(r'^partnumber/$', views.PartNumberListView.as_view(), name='partnumber_list'),
url(r'^partnumber/add/$', views.PartNumberCreateView.as_view(), name='partnumber_add'),
url(r'^partnumber/(?P<slug>[-\w]+)/$', views.PartNumberView.as_view(), name='partnumber_view'),
url(r'^partnumber/(?P<slug>[-\w]+)/update/$', views.PartNumberUpdateView.as_view(), name='partnumber_update'),
url(r'^partnumber/(?P<slug>[-\w]+)/delete/$', views.PartNumberDeleteView.as_view(), name='partnumber_delete'),
....
)
및 erp / settings / dev.py :
# Django settings for erp project.
# settings.py
from unipath import Path
PROJECT_DIR = Path(__file__).ancestor(3)
MEDIA_ROOT = PROJECT_DIR.child("media")
STATIC_ROOT = PROJECT_DIR.child("static")
STATICFILES_DIRS = (
PROJECT_DIR.child("assets"),
)
TEMPLATE_DIRS = (
PROJECT_DIR.child("templates"),
)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
TIME_ZONE = 'Australia/Melbourne'
LANGUAGE_CODE = 'en-au'
SITE_ID = 1
USE_TZ = True
DATE_FORMAT = 'd/m/y'
SHORT_DATE_FORMAT = 'd/m/y'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''
# 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: "/var/www/example.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# 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',
)
MIDDLEWARE_CLASSES = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'stronghold.middleware.LoginRequiredMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'erp.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'erp.wsgi.application'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.formtools',
'django.contrib.humanize',
'inventory',
'django_extensions',
'extra_views',
'debug_toolbar',
'django_tables2',
'stronghold',
'bootstrap3',
'haystack',
)
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
# For Stronghold
STRONGHOLD_PUBLIC_NAMED_URLS = (
'login',
'logout',
)
# This is required by the debug toolbar middleware
INTERNAL_IPS = ('192.168.0.16','0.0.0.0','127.0.0.1','::1', '192.168.0.115')
# This is reqquired by django_tables2
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request"
)
}
LOGIN_REDIRECT_URL = '/inventory/'
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
]
def show_toolbar(request):
return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'INSERT_BEFORE': '</body>',
'ENABLE_STACKTRACES': True,
}
# This is required for Haystack - the search engine
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8085/solr/erp',
},
}
내 wsgi는 마이너 설정 모드의 표준입니다.
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "erp.settings.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
내 apache2 / sites-avail / erp.conf는 다음과 같습니다.
<VirtualHost *:80>
ServerName deverp
ServerAdmin administrator
DocumentRoot /path/www/dev/erp/erp/
ErrorLog /var/log/apache2/dev/error.log
CustomLog /var/log/apache2/dev/access.log combined
WSGIDaemonProcess deverp python-path=/path/www/dev/erp/erp:/path/.virtualenvs/erp-dev/lib/python2.7/site-packages
WSGIProcessGroup deverp
WSGIScriptAlias / /path/www/dev/erp/erp/erp/wsgi.py
<Directory /path/www/dev/erp/erp/erp>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
그래서 실제로 비슷한 문제가 발생했습니다. 우연히 django-stronghold 에 대한 문제를 게시 한 후 . 이 문제는 사실 django-debug-toolbar의 설정이 누락 되었기 때문입니다.
누락 된 설정은 다음과 같습니다.
DEBUG_TOOLBAR_PATCH_SETTINGS = False
runserver와 함께 작동하지만 honcho, gunicorn 또는 WSGI 인터페이스를 사용하는 다른 모든 항목으로 실행하려고하면 폭발합니다.
도움이 되었기를 바랍니다!
편집 : @japhyr가 아래에서 언급했듯이 명시적인 설정 지침을 확인하는 데 유용합니다. http://django-debug-toolbar.readthedocs.org/en/1.0/installation.html#explicit-setup
I used reverse instead of reverse_lazy to define the url parameter of a RedirectView.
class YourRedirectView(RedirectView):
url = reverse('reversed_url')
Since the urls.py has not been initialized yet the error is coming up. Just use:
class YourRedirectView(RedirectView):
url = reverse_lazy('reversed_url')
I've suffered a similar problem after upgrading from django 1.5 to 1.6. I'm not sure if my experience is the same as yours.
First, can you scroll up the errors, and check the admin.autodiscover()
is what's generating the problem? Alternatively comment out this line and see if a page will load.
The problem I found was related to wsgi.py
. Is it possible for you to post this file?
I'm having a very similar problem. My project works fine on the test server, but when I try to deploy to gunicorn I get the same ImproperlyConfigured error.
If I comment out the urls which include another url file (i.e. url(r'^admin/', include(admin.site.urls)),
then the rest of my urls work fine.
[UPDATE] I was able to further narrow it down to only one of my included url files, but couldn't find anything special about it. However, setting Debug=False
in my settings.py
file seems to have fixed for me.
Also make sure you have urlpatterns
in the file you are including and that it is spelt correctly
'Programing' 카테고리의 다른 글
JavaScript에서 정수 자르기 / 반올림? (0) | 2020.11.23 |
---|---|
AttributeError : '모듈'개체에 'urlretrieve'속성이 없습니다. (0) | 2020.11.23 |
PostgreSQL에서 스키마를 생성 할 때 "오류 : 역할의 구성원이어야 함" (0) | 2020.11.23 |
터미널을 사용하여 Mac OS X에서 C 프로그램을 실행하는 방법은 무엇입니까? (0) | 2020.11.23 |
API Gateway CORS : 'Access-Control-Allow-Origin'헤더 없음 (0) | 2020.11.23 |