This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class View: | |
""" | |
Intentionally simple parent class for all views. Only implements | |
dispatch-by-method and simple sanity checking. | |
""" | |
http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'] | |
class APIView(View): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.views import APIView | |
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status, permissions, generics, viewsets | |
from rest_framework.response import Response | |
from django.shortcuts import get_object_or_404 | |
class StudentCurd(viewsets.ModelViewSet): | |
queryset = Student.objects.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.views import APIView | |
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status, permissions, generics, viewsets | |
from rest_framework.response import Response | |
from django.shortcuts import get_object_or_404 | |
class StudentCurd(viewsets.ViewSet): | |
permission_classes = [permissions.AllowAny] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.views import APIView | |
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status, permissions, generics, viewsets | |
from rest_framework.response import Response | |
from django.shortcuts import get_object_or_404 | |
class StudentCurd(viewsets.ViewSetMixin, generics.ListCreateAPIView, generics.RetrieveUpdateDestroyAPIView): | |
queryset = Student.objects.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.views import APIView | |
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status, permissions, generics | |
from rest_framework.response import Response | |
from django.shortcuts import get_object_or_404 | |
class StudentCurd(generics.ListCreateAPIView): | |
queryset = Student.objects.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.views import APIView | |
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status, permissions | |
from rest_framework.response import Response | |
from django.shortcuts import get_object_or_404 | |
class StudentCurd(APIView): | |
permission_classes = [permissions.AllowAny] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from curd.serializers import StudentSerializers | |
from curd.models import Student | |
from rest_framework import status | |
from rest_framework.response import Response | |
from rest_framework.decorators import api_view | |
from django.shortcuts import get_object_or_404 | |
@api_view(['GET', 'POST']) | |
def students_list_or_create(request): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from rest_framework import generics | |
from rest_framework.permissions import IsAdminUser, AllowAny | |
from .serializers import * | |
from .models import * | |
from rest_framework.renderers import JSONRenderer | |
from rest_framework.utils import encoders, json | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path('comments', my_views.Requirement.as_view(), name='requirements'), | |
path('requirement/<int:comment_id>/<str:opition>', my_views.UpdateCommentVote.as_view(), name='requirement_comment_vote'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container-1 left"> | |
<div class="f-card content"> | |
<h2>{{page_obj.created_at}}</h2> | |
<p>{{page_obj.comment}}.</p> | |
<div class="text-left"> | |
<span class="pointer"> | |
{% if request.user in page_obj.likes.users.all%} | |
<!-- already liked--> | |
<a href={% url 'requirement_comment_vote' comment_id=page_obj.pk opition='like' %}> <i | |
data-toggle="tooltip" data-placement="bottom" title="Unlike" |
NewerOlder