This commit is contained in:
parent
c862b72ac8
commit
2e251d7444
@ -16,7 +16,6 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path, reverse
|
||||
from django.views.generic.base import RedirectView
|
||||
from rest_framework import routers, schemas
|
||||
|
||||
import auth.urls
|
||||
import watchlist.urls
|
||||
@ -26,11 +25,10 @@ urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('auth/', include(auth.urls)),
|
||||
path('watchlist/', include(watchlist.urls)),
|
||||
# path('api/watchlist/', include(watchlist.urls.api_router.urls)),
|
||||
# path('openapi', schemas.get_schema_view(
|
||||
# title="Movieclub",
|
||||
# description="",
|
||||
# version="0.1.0"
|
||||
# )),
|
||||
# path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
|
@ -1,18 +0,0 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
|
||||
class MovieSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
suggested_by = serializers.ReadOnlyField(source="suggested_by.username")
|
||||
|
||||
class Meta:
|
||||
|
||||
model = models.Movie
|
||||
fields = ["url", "name", "watched", "suggested_by", "score"]
|
||||
|
||||
# class VoteSerializer(serializers.Serializer):
|
||||
|
||||
|
@ -1,10 +1,6 @@
|
||||
from django.urls import path
|
||||
from rest_framework import routers
|
||||
from . import views
|
||||
|
||||
api_router = routers.DefaultRouter()
|
||||
api_router.register(r'movie', views.MovieViewSet)
|
||||
|
||||
app_name = "watchlist"
|
||||
urlpatterns = [
|
||||
path('', views.IndexView.as_view(), name="index"),
|
||||
|
@ -5,24 +5,8 @@ from django.urls import reverse
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework import viewsets, permissions
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from . import serializers, models
|
||||
|
||||
class MovieViewSet(viewsets.ModelViewSet):
|
||||
queryset = models.Movie.objects.order_by('id').all()
|
||||
serializer_class = serializers.MovieSerializer
|
||||
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(owner=self.request.user)
|
||||
|
||||
# @action(detail=True, methods=["POST"])
|
||||
# def vote(self, request, pk=None):
|
||||
# movie = self.get_object()
|
||||
# vote = request.date.get("vote", 0)
|
||||
|
||||
from . import models
|
||||
|
||||
class IndexView(generic.ListView):
|
||||
template_name = "watchlist/index.html"
|
||||
|
Loading…
Reference in New Issue
Block a user