Browse Source

Praktikum 8 v2

devel
Heimbs 5 years ago
parent
commit
9b3eb7090a
1 changed files with 4 additions and 0 deletions
  1. 4
    0
      news/posts/views.py

+ 4
- 0
news/posts/views.py View File

import logging import logging

from django.shortcuts import render, redirect, render_to_response from django.shortcuts import render, redirect, render_to_response
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.utils import timezone from django.utils import timezone
from django.contrib import messages from django.contrib import messages
from django.views.decorators.csrf import csrf_exempt


from rest_framework.renderers import JSONRenderer from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser from rest_framework.parsers import JSONParser
return redirect('posts') return redirect('posts')
@csrf_exempt
def notice_list(request): def notice_list(request):
if request.method == 'GET': if request.method == 'GET':
notices = Notice.objects.all() notices = Notice.objects.all()
return JsonResponse(serializer.errors, status=400) return JsonResponse(serializer.errors, status=400)




@csrf_exempt
def notice_detail(request, id): def notice_detail(request, id):
try: try:
notice = Notice.objects.get(id=id) notice = Notice.objects.get(id=id)

Loading…
Cancel
Save