Skip to content

Instantly share code, notes, and snippets.

@ikks
Created September 24, 2012 12:45
Show Gist options
  • Save ikks/3775774 to your computer and use it in GitHub Desktop.
Save ikks/3775774 to your computer and use it in GitHub Desktop.
Cart Sale Model Sample
class CartSale(models.Model):
first_name = models.CharField(
max_length=100,
)
last_name = models.CharField(
max_length=100,
)
date_sale = models.DateTimeField(
auto_now_add=True,
)
email = models.EmailField()
class CartProduct(models.Model):
upc = models.CharField(
max_length=100,
)
cartsale = models.ForeignKey(
CartSale,
related_name='products',
)
quantity = models.IntegerField()
price = models.DecimalField(
max_digits=8,
decimal_places=2,
)
product_detail = models.ForeignKey(
ProductDetail,
)
class Product(models.Model):
name = models.CharField(
max_length=30,
)
reference = models.CharField(
max_length=30,
)
class ProductDetail(models.Model):
price = models.DecimalField(
max_digits=8,
decimal_places=2,
)
quantity = models.PositiveIntegerField(
blank=True,
default=0,
)
upc = models.CharField(
max_length=100,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment