我有一些正在工作的视图,但是现在我添加了一个新视图,它不再起作用,并且我不断收到错误消息ViewDoesNotExist
。
追溯:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 101.request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve 300.sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
209. return ResolverMatch(self.callback, args, kwargs, self.name)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in callback 216. self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in wrapper 27.result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in get_callable 101.(lookup_view, mod_name))
Exception Type: ViewDoesNotExist at /login/
Exception Value: Could not import owners.views.login_request. View does not exist in module owners.views.
关于我可能做错的任何其他信息/指示都会有所帮助。
我的观点
def login_request(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile')
elif request.method == 'POST':
form = Loginform(request.POST)
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
site_user = authenticate(username= username,password = password )
if site_user is not None:
login(request,site_user)
return HttpResponseRedirect('/profile')
else:
return render_to_response('login.html',{'form':form},context_instance = RequestContext(request))
else:
return render_to_response('login.html',{'form':form},context_instance = RequestContext(request))
else:
'''user not subinting show loging form'''
form = Loginform()
context = {'form': form}
return render_to_response('login.html',context,context_instance = RequestContext(request))
我的网址看起来像这样
(r'^login/$','owners.views.login_request'),
我有大约 70 次观看,但只有 '/' 有效