代码是
#urls.py
from django.conf.urls import patterns, url
from employees import views
from schdeules import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
url(r'^accounts/$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
url(r'^accounts/profile/$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
)
#views.py
# Create your views here.
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
@login_required
def home(request):
welecome = 'hai welcome to opas'
context = {'temp_var': welecome}
return render(request, 'schdeules/home.html')
and iam getting an error
Exception Type: ViewDoesNotExist at /opas/
Exception Value: Could not import django.views.generic.simple.redirect_to. Parent module django.views.generic.simple does not exist.
我想使用 django 默认登录和注销模块。如果成功登录,那么我想重定向到主页。提前致谢。