On Saturday, April 12, 2014 1:10:34 AM UTC-4:30, Kimitaka wrote:
>
> I wrote the function in my Product class in my models.py:
> class Product(models.Model):
> title = models.CharField(max_length=220)
> description = models.CharField(max_length=3000, null=True, blank=True)
> price = models.DecimalField(max_digits=1000, decimal_places=2, null=True, 
> blank=True)
> slug = models.SlugField()
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
> updated = models.DateTimeField(auto_now_add=True, auto_now=False)
> active = models.BooleanField(default=True)
>
> def __unicode__(self):
> return self.title
> class Meta:
> ordering = ['title',]
>
> *def shorten_words(self):*
> * if len(self.description) > 20:*
> * print self.desciption[0:20]*
> * else:*
> * print self.desciption*
>
>
> and I added a code in my products.html page:
> {{ product.description*.shorten_words()* }}
>
Hello,

Should it be?:
{{ product.shorten_words }} 

Regards,
Camilo

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/070e50c3-73bb-4f99-a425-8ed2125fc005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to