help me please...
---------------------------------------------------------------------------------------------------
from django.db import models
class Catalog(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(max_length=150)
publisher = models.CharField(max_length=300)
description = models.TextField()
pub_date = models.DateTimeField('date published')
class CatalogCategory(models.Model):
catalog = models.ForeignKey(Catalog, related_name='categories')
parent = models.ForeignKey('self', blank=True, null=True, related_name='children')
name = models.CharField(max_length=255)
slug = models.SlugField(max_length=255, unique=True)
description = models.TextField(blank=True)
date = models.DateTimeField('date published')
def __unicode__(self):
if self.parent:
class Product(models.Model):
category = models.ForeignKey(CatalogCategory, related_name='products')
name = models.CharField(max_length=255)
slug = models.SlugField(max_length=255)
description = models.TextField()
photo = models.ImageField(upload_to='product_photo', blank=True)
manufacturer = models.CharField(max_length=255, blank=True)
price_in_dollars = models.DecimalField(max_digits=6,decimal_places=2)
class ProductAttribute(models.Model):
name = models.CharField(max_length=300)
description = models.TextField(blank=True)
def __unicode__(self):
class ProductDetail(models.Model):
product = models.ForeignKey(Product, related_name='details')
attribute = models.ForeignKey(ProductAttribute)
value = models.CharField(max_length=500)
description = models.TextField(blank=True)
def __unicode__(self):
return u'%s: %s - %s' % (self.product, self.attribute, self.value)