On Fri, 2011-07-15 at 11:14 -0700, Suprnaturall wrote:
> class Category(models.Model):
> name = models.CharField(max_length=250)
>
> def get_short_name():
> return name[0,20]
def get_short_name(self)
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
On 15 juil, 20:14, Suprnaturall wrote:
> Hi,
>
> I'm wondering if like in play or symfony you can develop special
> method for each class/table in the models.py and use them in your
> template.
Of course. A model is "just" a Python class (well, with some "magic"
but...).
> I'm trying few things
Oh crap i m feel ashame...
Thanx for your help !
On Fri, Jul 15, 2011 at 8:46 PM, Shawn Milochik wrote:
> On 07/15/2011 02:14 PM, Suprnaturall wrote:
>
>> def get_short_name():
>>return name[0,20]
>>
>
> Try this:
> def get_short_name(self):
>
>return self.name[0:20]
>
>
>
On 07/15/2011 02:14 PM, Suprnaturall wrote:
def get_short_name():
return name[0,20]
Try this:
def get_short_name(self):
return self.name[0:20]
You need 'self' in two places, and I assume you want a string of the
first 20 characters rather than a list of the first and
Hi,
I'm wondering if like in play or symfony you can develop special
method for each class/table in the models.py and use them in your
template.
I'm trying few things but it didn't work.
For exemple this is my models.py :
class Category(models.Model):
name = models.CharField(max_length=250)
5 matches
Mail list logo