Hi, I started learning Django(also new to Python) and I would like to use
it in Japanese.
Since truncatewords doesn't seem working in non-English language, I tried
to create a resembling function.
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()* }}
And it's not working..
Could you give me some advices?
Thank you!
--
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/0f18a1dd-27de-4f7b-a4ac-d59bb77550a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.