Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Variation(models.Model):
- barcode = models.CharField(max_length=255, unique=True, null=True, blank=True,)
- sku = models.CharField(max_length=255, unique=True, null=False, blank=False)
- title = models.CharField(max_length=255, null=False, unique=False)
- price = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
- cost = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
- stock_level = models.IntegerField(null=False, blank=False)
- weight = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=5)
- height = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=5)
- width = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=5)
- length = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=5)
- is_master = models.BooleanField()
- image_id = models.IntegerField(null=True, blank=True)
- product = models.ForeignKey(Product, related_name='variations') \
- # Reference to Product Model
- created_at = models.DateTimeField(auto_now_add=True)
- updated_at = models.DateTimeField(auto_now=True)
- # 'Magic Method'Helps to view instances of a django model.
- def __unicode__(self): # __str__ on Python 3
- return self.title
- # Property Table called ExtraField
- class ExtraField(models.Model):
- '''
- This Model will hold any extra properity or data associated with any
- specific variation.
- '''
- variation = models.ManyToManyField(Variation) # reference to Variation
- title = models.CharField(max_length=255)
- description = models.CharField(max_length=255)
- created_at = models.DateTimeField(auto_now_add=True)
- updated_at = models.DateTimeField(auto_now=True)
- # 'Magic Method'Helps to view instances of a django model.
- def __unicode__(self): # __str__ on Python 3
- self self.title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement