Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Not Found: /ajax_result/
- [07/Apr/2020 12:48:14] "POST /ajax_result/ HTTP/1.1" 404 1742
- НО
- в урлс:
- path('ajax_result/', views.AjaxResultView.as_view(), name='ajax_result'),
- во вьювс:
- class AjaxResultView(View):
- def post(self, request):
- user = request.user
- user_profile = get_object_or_404(Profile, user=user)
- score = request.POST.get('result')
- if score:
- # Create object of game
- GameSession.objects.create(
- user=user,
- score=score
- )
- # Update user info
- user_profile.update(games_played=F('games_played') + 1)
- if score > user_profile.high_score:
- user_profile.update(high_score=score)
- # Showing result
- data = {
- 'is_success': True,
- }
- redirect(ResultView)
- return JsonResponse(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement