Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gindi Khangura 2019-July-27 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode/
env3/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
15 changes: 13 additions & 2 deletions ecommerce/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
from products.models import Product, Category


class ProductSerializer():
class ProductSerializer(serializers.ModelSerializer):
# YOUR CODE HERE
pass
class Meta:
model = Product
fields = (
'id',
'name',
'sku',
'category',
'description',
'price',
'created',
'featured',
)
2 changes: 1 addition & 1 deletion ecommerce/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
router = DefaultRouter()

# Register the 'products' urls in the router
router.register('...')
router.register('products', views.ProductViewSet, base_name='products')

urlpatterns = []
urlpatterns += router.urls
5 changes: 5 additions & 0 deletions ecommerce/api/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from rest_framework import viewsets

from products.models import Product
from api.serializers import ProductSerializer


# YOUR VIEWS HERE
class ProductViewSet(viewsets.ModelViewSet):
serializer_class = ProductSerializer
queryset = Product.objects.all()