Thursday, July 31, 2014

Re: invalid attribute

Do you have the full error message?


On Thursday, July 31, 2014 5:48:55 PM UTC-4, ngangsia akumbo wrote:
Got an invalid attribut error

class Product(models.Model):
    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255, unique=True,
            help_text="Each product has a unique name")
    brand = models.CharField(max_length=50)
    sku = models.CharField(max_length=50)
    price = models.DecimalField(max_length=9, decimal_places=3)
    old_price = models.DecimalField(max_length=9, decimal_places=3, blank=True, default=0.00)
    image = models.CharField(max_length=50)
    is_active = models.BooleanField(default=True)
    is_bestseller = models.BooleanField(default=False)
    is_featured = models.BooleanField(default=False)
    quantity = models.IntegerField()
    description = models.TextField()
    meta_keywords = models.CharField('Meta Keywords', max_length=300)
    meta_description = models.CharField("Meta Description", max_length=255)
       
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    category = models.ManyToManyField(Category)


    class Meta:
        db_table = 'products'
        ordering = ['-created_at']

        def __unicode(self):
            return self.name


        @models.permalink
        def get_absolute_url(self):
            return ('catalog_product', (), { 'product_slug': self.slug })

       
        def sale_price(self):
            if self.old_price > self.price:
                return self.price
            else:
                return None

       
   

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/917e4e0c-89fe-4c11-8fb4-a26a1f4c9550%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment