Search api lari tayyor
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from .category import * # noqa
|
||||
from .search import * # noqa
|
||||
|
||||
1
core/apps/api/serializers/search/__init__.py
Normal file
1
core/apps/api/serializers/search/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .search import * # noqa
|
||||
27
core/apps/api/serializers/search/search.py
Normal file
27
core/apps/api/serializers/search/search.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from rest_framework import serializers
|
||||
from core.apps.accounts.models import SearchHistory
|
||||
|
||||
|
||||
class BaseSearchHistorySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = SearchHistory
|
||||
fields = [
|
||||
"value",
|
||||
]
|
||||
|
||||
|
||||
class ListSearchHistorySerializer(BaseSearchHistorySerializer):
|
||||
class Meta(BaseSearchHistorySerializer.Meta): ...
|
||||
|
||||
|
||||
class RetrieveSearchHistorySerializer(BaseSearchHistorySerializer):
|
||||
class Meta(BaseSearchHistorySerializer.Meta): ...
|
||||
|
||||
|
||||
class CreateSearchHistorySerializer(BaseSearchHistorySerializer):
|
||||
class Meta(BaseSearchHistorySerializer.Meta): ...
|
||||
|
||||
def create(self, validated_data):
|
||||
validated_data['user'] = self.context['request'].user
|
||||
history = SearchHistory.objects.create(**validated_data)
|
||||
return history
|
||||
Reference in New Issue
Block a user