modeling wishes
This commit is contained in:
parent
6254bf48a5
commit
16e32c94aa
|
@ -37,6 +37,7 @@ INSTALLED_APPS = (
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'wish',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
|
|
|
@ -3,17 +3,42 @@ from django.db import models
|
|||
import uuid
|
||||
|
||||
class Wishlist(models.Model):
|
||||
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
external_id = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def create(name, description):
|
||||
w = Wishlist()
|
||||
w.name = name
|
||||
w.description = description
|
||||
w.save()
|
||||
return w
|
||||
|
||||
class Item(models.Model):
|
||||
pass
|
||||
|
||||
wishlist = models.ForeignKey(Wishlist, related_name='items')
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
picture = models.ImageField(null=True)
|
||||
numbers_available = models.IntegerField(default=1)
|
||||
number_of_parts = models.IntegerField(null=True)
|
||||
estimated_price = models.DecimalField(max_digits=19, decimal_places=2,
|
||||
null=True)
|
||||
|
||||
@staticmethod
|
||||
def create(name, description, wishlist):
|
||||
i = Item()
|
||||
i.name = name
|
||||
i.description = description
|
||||
i.wishlist = wishlist
|
||||
i.save()
|
||||
return i
|
||||
|
||||
class Part(models.Model):
|
||||
pass
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
django
|
||||
pillow
|
||||
|
|
Loading…
Reference in New Issue