On Feb 2, 8:39 pm, Alex Jonsson <alex.e.jons...@gmail.com> 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 get to check if a tag is included in > an object is to run a ifequal, and that's no good. > > Hopefully you get my point? > > Thanks, > Alex >
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): return 'sports' in self.tag_list def is_personal(self): return 'personal' in self.tag_list Is that what you want? It'll get unmaintainable pretty fast, though. -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---