def rater_page(request, rater_id): try: rater = Rater.objects.get(rater=rater_id) rated_mov = Rater.movies_rated(rater) except Movie.DoesNotExist: raise Http404 context = {'rater': rater, 'rated_movies': rated_mov} if request.user == rater.user: if request.POST: rate_instance = Rating(rater=rater) form = RatingForm(request.POST, instance=rate_instance) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("best_movies")) form = RatingForm() context['form'] = form return render_to_response('ratings/rater.html', context, context_instance=RequestContext(request))
def import_raters(apps, schema_editor): with open('ratings/data/raters.csv', encoding='latin-1') as f: raters = csv.reader(f, delimiter="|") for row in raters: rater = Rater(age=row[1], sex=row[2], occupation=row[3]) rater.save()