Created
May 18, 2011 18:03
-
-
Save mbrochh/979127 to your computer and use it in GitHub Desktop.
Product models for django-shop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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