Skip to content

Instantly share code, notes, and snippets.

@spapas
Created August 22, 2013 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spapas/6305393 to your computer and use it in GitHub Desktop.
Save spapas/6305393 to your computer and use it in GitHub Desktop.
Sample django models
class Category(models.Model):
name = models.CharField()
class Attribute(models.Model):
category = models.ForeignKey(Category)
name = models.CharField
class Item(models.Model):
slug = models.SlugField()
price = models.DecimalField()
remaining = models.IntegerField()
category = models.ForeignKey(Category)
description = models.CharField()
attributes = models.ManyToManyField(Attribute, through='ItemAttribute')
class ItemAttribute(models.Model):
item= models.ForeignKey(Item)
attribute = models.ForeignKey(Attribute)
value = models.CharField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment