Created
August 17, 2017 19:50
-
-
Save LucasMagnum/36cac695f9b39de1a5ebce1ac5184afe to your computer and use it in GitHub Desktop.
Product list #djangotips02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .models import Product | |
def products_list(): | |
product_qs = Product.objects.all() | |
products = [] | |
for product in product_qs: | |
products.append({ | |
'id': product.id, | |
'title': product.title, | |
'category': product.category.name | |
}) | |
return products |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment