Skip to content

Commit 2c1768e

Browse files
committed
add to_json method in product model
1 parent a73a43f commit 2c1768e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

store/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ class Product(models.Model):
1717

1818
def __str__(self):
1919
return str(self.name)
20+
21+
def to_json(self):
22+
return {
23+
'name': str(self.name),
24+
'description': str(self.description),
25+
'price': str(self.price),
26+
'timestamp': str(self.timestamp),
27+
'updated': str(self.updated),
28+
}

0 commit comments

Comments
 (0)