Skip to content

Commit

Permalink
Merge pull request #1 from Abramov0Alexandr/feature
Browse files Browse the repository at this point in the history
Сделал фильтрацию пользователей по статусу (продавец/посетитель)
  • Loading branch information
Abramov0Alexandr committed Sep 24, 2023
2 parents e813095 + bb9ea8b commit 90c9d96
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
12 changes: 11 additions & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
'django.contrib.messages',
'django.contrib.staticfiles',

'rest_framework',
'django_extensions',
'django_filters',

'custom_user.apps.CustomUserConfig',
]
Expand All @@ -56,6 +58,10 @@
# Setting the permission policy
# https://www.django-rest-framework.org/api-guide/permissions/#setting-the-permission-policy

# Integration with Django Rest Framework is provided through a DRF-specific FilterSet and a filter backend.
# These may be found in the rest_framework sub-package.
# https://django-filter.readthedocs.io/en/stable/guide/rest_framework.html

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
Expand All @@ -65,7 +71,11 @@
'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.IsAuthenticated',
'rest_framework.permissions.AllowAny',
]
],

'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
),
}

# Some of Simple JWT’s behavior can be customized through settings variables in settings.py
Expand Down
3 changes: 3 additions & 0 deletions custom_user/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import generics
from custom_user.models import CustomUser
from custom_user.serializers import CustomUserListSerializer, CustomUserCreateSerializer
Expand All @@ -8,6 +9,8 @@ class CustomUserListView(generics.ListAPIView):

serializer_class = CustomUserListSerializer
queryset = CustomUser.objects.all()
filter_backends = [DjangoFilterBackend]
filterset_fields = ('is_seller', )


class CustomUserCreateView(generics.CreateAPIView):
Expand Down
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ coverage = "^7.3.1"
flake8 = "^6.1.0"
django-extensions = "^3.2.3"
ipython = "^8.15.0"
django-filter = "^23.3"


[build-system]
Expand Down

0 comments on commit 90c9d96

Please sign in to comment.