Re: Customized model methods

2009-02-02 Thread Jacolyte
On Feb 2, 4:57 pm, Alex Jonsson wrote: > On Feb 2, 9:50 pm, Daniel Roseman > wrote: > > > > > You can define as many methods on a model as you like. Models are just > > Python classes, and you can do anything with them that you would do > > with a normal class. > > > def MyModel(models.Model): >

Re: Customized model methods

2009-02-02 Thread Alex Jonsson
On Feb 2, 9:50 pm, Daniel Roseman wrote: > You can define as many methods on a model as you like. Models are just > Python classes, and you can do anything with them that you would do > with a normal class. > > def MyModel(models.Model): >     ... field definitions ... > >     def is_sports(self)

Re: Customized model methods

2009-02-02 Thread Daniel Roseman
On Feb 2, 8:39 pm, Alex Jonsson wrote: > Dave, > > Thank you for your answer. Thing is, I already use django-tagging. > > I was a bit unclear: I'd like the function to return True or False, so > that I can run some logic on it based on that. When I use django- > tagging today the closest I can ge

Re: Customized model methods

2009-02-02 Thread Alex Jonsson
Dave, Thank you for your answer. Thing is, I already use django-tagging. I was a bit unclear: I'd like the function to return True or False, so that I can run some logic on it based on that. When I use django- tagging today the closest I can get to check if a tag is included in an object is to r

Re: Customized model methods

2009-02-01 Thread Dave Fowler
Well you might want to start by looking into django-tagging http://code.google.com/p/django-tagging/wiki/UsefulTips Install that for easy tags, and that link to the useful tips shows how to retrieve and set tags. Also instead of doing a lot of is_this() and is_that() you will probably want to d

Customized model methods

2009-02-01 Thread Alex Jonsson
Hey guys, I'm looking to create a model method like is_(), where the tag can be used to lookup if the object is tagged with a certain ... tag. Kind of like this: A blog entry is tagged "personal" and "funny". >> blog_entry.is_sports() False >> blog_entry.is_personal() True >> blog_entry.is_what