我收到以下错误
Django Version: 1.4
Exception Type: ViewDoesNotExist
Exception Value:
Could not import ratings.views.HotelRating. View does not exist in module ratings.views.
但这是我的views.py
from django.http import HttpResponseRedirect
from django.contrib.auth.models import User
from django.shortcuts import render_to_response
from ratings.models import Hotel_Rating, Restaurant_Rating, Cafe_Rating, Pastry_Rating
from services.models import *
from ratings.forms import Hotel_Rating_From
from django.template import RequestContext
def HotelRating(request):
if request.method == 'POST':
form = Hotel_Rating_From(request.POST)
if form.is_valid():
user_id = form.cleaned_data['user_id']
hotel_id = form.cleaned_data['hotel_id']
user = User.objects.get(id = user_id)
hotel = Hotel.objects.get(id = hotel_id)
review = Hotel_Rating(hotel_id = hotel.id, user_id = user.id, overall_rating = form.cleaned_data['overall_rating'], service = form.cleaned_data['service'], cleanliness = form.cleaned_data['cleanliness'], location = form.cleaned_data['location'], rooms = form.cleaned_data['rooms'], restaurant = form.cleaned_data['restaurant'], room_service = form.cleaned_data['room_service'], price = form.cleaned['price'], comment = form.cleaned_data['comment'])
review.save()
return HttpResponseRedirect('/')
else:
form = Hotel_Rating_From(request.POST)
return render_to_response('hotelreview.html', {'form': form}, context_instance = RequestContext(request))
这是我的urls.py
文件
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
(r'^register/$', 'reviewers.views.ReviewerRegistration'),
(r'^hotelrating/$', 'ratings.views.HotelRating'),
(r'^login/$', 'reviewers.views.LoginRequest'),
)
我不知道我做错了什么,我在 settings.py 的 INSTALLED_APPS 中添加了评分应用程序。