Mercurial > public > sg101
comparison contests/views.py @ 679:89b240fe9297
For Django 1.5.2: import json; django.utils.simplejson is deprecated.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 15 Aug 2013 20:14:33 -0500 |
parents | ee87ea74d46b |
children | 16e190fa6ef8 |
comparison
equal
deleted
inserted
replaced
678:38a198ea8c61 | 679:89b240fe9297 |
---|---|
1 """ | 1 """ |
2 Views for the contests application. | 2 Views for the contests application. |
3 | 3 |
4 """ | 4 """ |
5 import json | |
6 | |
5 from django.http import (HttpResponse, HttpResponseForbidden, | 7 from django.http import (HttpResponse, HttpResponseForbidden, |
6 HttpResponseBadRequest) | 8 HttpResponseBadRequest) |
7 from django.shortcuts import get_object_or_404 | 9 from django.shortcuts import get_object_or_404 |
8 from django.utils import simplejson | |
9 from django.views.decorators.http import require_POST | 10 from django.views.decorators.http import require_POST |
10 | 11 |
11 from contests.models import Contest | 12 from contests.models import Contest |
12 | 13 |
13 | 14 |
40 else: | 41 else: |
41 contest.contestants.add(request.user) | 42 contest.contestants.add(request.user) |
42 result['entered'] = True | 43 result['entered'] = True |
43 result['msg'] = 'You have been entered into this contest!' | 44 result['msg'] = 'You have been entered into this contest!' |
44 | 45 |
45 json = simplejson.dumps(result) | 46 json_result = json.dumps(result) |
46 return HttpResponse(json, content_type='application/json') | 47 return HttpResponse(json_result, content_type='application/json') |