VIEWS
class PageView(viewsets.ModelViewSet):
serializer_class = postserializer
# queryset = Page.objects.all()
def get_queryset(self,request,*args,**kwargs,):
queryset = Page.objects.all()
return Page.objects.filter(event=self.kwargs['author'])
URLS
router = routers.DefaultRouter()
router.register('^author/(?P<author>.+)/$', PageView ,basename="author")
router.register(r'authors',views.AuthorView, basename="authors")
urlpatterns = [
path("", include(router.urls))
]
Model
class Page(models.Model):
author = models.CharField(max_length=30)
post = models.TextField()
how to search for particular authors of my post like /author/bob/
i've been trying to follow offical documentation but its unclear to me :\
http://www.tomchristie.com/rest-framework-2-docs/api-guide/filtering
PageViewclass? If so, please post it here.