Skip to content

Instantly share code, notes, and snippets.

@LucasMagnum
Created August 17, 2017 19:50
Show Gist options
  • Save LucasMagnum/36cac695f9b39de1a5ebce1ac5184afe to your computer and use it in GitHub Desktop.
Save LucasMagnum/36cac695f9b39de1a5ebce1ac5184afe to your computer and use it in GitHub Desktop.
Product list #djangotips02
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