Skip to content

Instantly share code, notes, and snippets.

@mbrochh
Created May 18, 2011 18:03
Show Gist options
  • Save mbrochh/979127 to your computer and use it in GitHub Desktop.
Save mbrochh/979127 to your computer and use it in GitHub Desktop.
Product models for django-shop
from django.db import models
from shop.models.productmodel import Product
class Category(models.Model):
"""Master data: Names of categories."""
name = models.CharField(max_length=256)
def __unicode__(self):
return self.name
class Distributor(models.Model):
"""Master data: Information about distributors."""
name = models.CharField(max_length=256)
def __unicode__(self):
return self.name
class LED(Product):
"""Product class for LED lamps."""
article_number = models.IntegerField()
distributor = models.ForeignKey(Distributor)
image1 = models.ImageField(blank=True, upload_to='myshop_images')
image2 = models.ImageField(blank=True, upload_to='myshop_images')
# name - resides in Product base class
category = models.ForeignKey(Category, blank=False, null=False)
weight = models.FloatField(blank=True, null=True)
def __unicode__(self):
return '[%s] %s' % (self.article_number, self.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment