Skip to content

Commit

Permalink
backend: category api - view separated
Browse files Browse the repository at this point in the history
  • Loading branch information
rkshaon committed Jul 23, 2024
1 parent 8eb5bfb commit b70174a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ backend/media
backend/configure_api/__pycache__
backend/configure_api/migrations
backend/configure_api/urls/__pycache__
backend/configure_api/views/__pycache__
backend/configure_api/views/__pycache__
__pycache__
8 changes: 4 additions & 4 deletions backend/category_api/urls/v1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.urls import path

from category_api import views
from category_api.views import v1 as v1_view


urlpatterns = [
path('', views.CategoryView.as_view()),
path('<int:pk>', views.CategoryView.as_view()),
]
path('', v1_view.CategoryView.as_view()),
path('<int:pk>', v1_view.CategoryView.as_view()),
]
File renamed without changes.
8 changes: 4 additions & 4 deletions backend/product_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class Meta:
model = Product
fields = '__all__'


def to_representation(self, instance):
representation = super().to_representation(instance)

representation['images'] = [
ProductImageSerializer(image).data for image in instance.images.all()
ProductImageSerializer(
image).data for image in instance.images.all()
]
return representation


class ProductImageSerializer(serializers.ModelSerializer):
class Meta:
model = ProductImage
fields = '__all__'
fields = '__all__'

0 comments on commit b70174a

Please sign in to comment.