alain D. schrieb:
> Being inside database transactions is a good reason to use database's
> full text index ... but the sake of simplicity, a full text index
> created by python code inside the models declaration (easily
> maintainable) would be nice ...
>
>
>   
This is inside the model declaration:

class MyModel(models.Model):
    ...
    def save(self, text_update=True):
        models.Model.save(self)
        if text_update:
            text=utils.mymodel_to_text(self)
            tsvector=tsearchutils.to_tsvector(text)
            cursor=connection.cursor()
            cursor.execute(u'''UPDATE myapp_mymodel SET
content=%s::tsvector where id=%s''', [tsvector, self.id])

The column "content" of type tsvector is created by a SQL snippet named
mymodel.sql.

HTH,
  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to