我已将 urls.py 文件中的 url 指定为url(r'^register/$', 'drinker.views.drinker_reg'),
我在views.py 文件中创建了drinker_reg 视图。
views.py 的代码是:
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from drinker.forms import RegistrationForm
def drinker_reg(request):
if request.user.is_authenticated():
return HttpResponseRedirect("/profile/")
if request.method == 'POST':
pass
else:
''' user is not submitting the form, show them a blank registration form '''
form=RegistrationForm()
context={'form':form}
return render_to_response('registration.html', context, context_instance=RequestContext(request))
但我仍然在 /register 处收到错误 ViewDoesNotExist 无法导入 Drinker.views.drinker_reg。模块drinker.views 中不存在视图。
为什么?