Python Django重定向快捷方式
我试图使用重定向快捷方式发出重定向,但我收到以下错误Python Django重定向快捷方式,python,django,Python,Django,我试图使用重定向快捷方式发出重定向,但我收到以下错误 raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name) ImproperlyConfigured: The included urlconf webtools.urls doesn't have any patterns in it 我的URL.py文件如下所示: from django
raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name)
ImproperlyConfigured: The included urlconf webtools.urls doesn't have any patterns in it
我的URL.py文件如下所示:
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import direct_to_template
from django.views.generic.base import RedirectView
from django.shortcuts import redirect
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
url(r'^.*$', redirect(macmonster.views.home)),
)
您的url模式似乎有点奇怪,请尝试:
url(r'^(.*)$', redirect('macmonster.views.home')),
您的url模式似乎有点奇怪,请尝试:
url(r'^(.*)$', redirect('macmonster.views.home')),
我现在得到-->名称错误:名称“macmonster”未定义(??)你需要导入你的“macmonster”应用程序或使用quotesDjango找不到你的应用程序。您确定
macmonster.views.home
是您视图的正确“路径”吗?不确定您使用的是哪个版本的Django,但重定向快捷方式已被弃用。如果您使用的是1.3或更高版本,则GenericView是首选方法。类似于url(r'^(.*)$),RedirectView.as_view(url='/relativePathUriForHomeView'),另一种方法是使用重定向到({'url':'path/to/homepage'})
我现在得到-->名称错误:没有定义名称“macmonster”(?)你需要导入你的“macmonster”应用程序或使用quotesDjango找不到你的应用程序。您确定macmonster.views.home
是您视图的正确“路径”吗?不确定您使用的是哪个版本的Django,但重定向快捷方式已被弃用。如果您使用的是1.3或更高版本,则GenericView是首选方法。类似url(r'^(.*),RedirectView.as_view(url='/relativePathUriForHomeView')),另一种方法是使用redirect_到({'url':'path/to/homepage'})