These are chat archives for django/django

17th
Jan 2018
Prateek Dabas
@dprateek11
Jan 17 2018 07:13
File "/Users/prateekdabas/Desktop/trydjango19/src/trydjango19/urls.py", line 29, in <module>
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
i am getting this error
TypeError: 'module' object is not callable
Kaushal Kumar
@kaushal087
Jan 17 2018 12:23

How can I use permission classes on certain method of class based views.

i.e.,

from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

class ExampleView(APIView):
    permission_classes = (IsAuthenticated,)

    def get(self, request, format=None):
        content = {
            'status': 'request was permitted'
        }
        return Response(content)
    def put(self, request, format=None):
        content = {
            'status': 'request was permitted'
        }
        return Response(content)

What if I want to attach different permission classes on get and post methods.
I can't use function based views as I have to attach the permission on many APIs possible to change code structure as we follow class based view practice.

André Cruz
@edevil
Jan 17 2018 13:22
Is there a way to configure connection pooling using the postgres backend?
Anish Shrestha
@annshress
Jan 17 2018 14:05
@kaushal087 use permission classes decorators