コード例 #1
0
ファイル: views.py プロジェクト: pnitto/django-movies
def rater_detail(request, user_id):
    rater = Rater.objects.get(id=user_id)
    if request.POST:
        print("It posted!", request.POST)
        request.POST['rater'] = request.user
        form = RatingForm(request.POST)
        form.save()
        context = {"rater" : rater, "form" : form}
        return render_to_response("rater_detail.html",context,context_instance=RequestContext(request))

    form = RatingForm()
    context = {"rater" : rater, "form" : form}
    return render_to_response("rater_detail.html",context,context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: traciarms/django-movies
def change_rating(request, rating_id):

    if request.method == 'POST':
        form = RatingForm(request.POST)

        if form.is_valid():
            rating = Rating.objects.get(pk=rating_id)
            form_rating = form.save(commit=False)
            rating.movie_id = rating.movie.id
            rating.rater_id = request.user.rater.id
            rating.new_stamp = datetime.datetime.now()
            rating.ratings = form_rating.ratings
            rating.save()

            return HttpResponseRedirect(reverse('account_profile'))

    else:
        form = RatingForm()
    return render(request, 'app1/update_rating.html', {'form': form,
                                                       'rating_id': rating_id})