Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-pgindex

How to install django-pgindex

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-pgindex
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.8.1 Available View build log
0.7.1 Available View build log
0.6.0 Available View build log
0.5.1 Available View build log
0.5.0 Available View build log
0.4.0 Available View build log
0.3 Available View build log
0.2 Available View build log
Windows (64-bit)
0.8.1 Available View build log
0.7.1 Available View build log
0.6.0 Available View build log
0.5.1 Available View build log
0.5.0 Available View build log
0.4.0 Available View build log
0.3 Available View build log
0.2 Available View build log
Mac OS X (10.5+)
0.8.1 Available View build log
0.7.1 Available View build log
0.6.0 Available View build log
0.5.1 Available View build log
0.5.0 Available View build log
0.4.0 Available View build log
0.3 Available View build log
0.2 Available View build log
Linux (32-bit)
0.8.1 Available View build log
0.7.1 Available View build log
0.6.0 Available View build log
0.5.1 Available View build log
0.5.0 Available View build log
0.4.0 Available View build log
0.3 Available View build log
0.2 Available View build log
Linux (64-bit)
0.8.1 Available View build log
0.7.1 Available View build log
0.6.0 Available View build log
0.5.1 Available View build log
0.5.0 Available View build log
0.4.0 Available View build log
0.3 Available View build log
0.2 Available View build log
 
License
BSD
Lastest release
version 0.8.1 on Aug 10th, 2011

Search for Django and PostgreSQL.

Requirements

  • Django >= 1.1
  • django-stringfield >= 0.1.5
  • django-cerial >= 0.0.2

Installation

First install the package from pypi using pip:

pip install django-pgindex

Then make pgindex an app in your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'pgindex',
    ...
)

Sync your database:

python manage.py syncdb

Done.

Usage

Create and Index class and register it to your model, much like registering an admin class to your model. Example:

# models.py
from django.db import models
from .index import ItemIndex
from pgindex import register

class Item(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()

    def get_absolute_url(self):
        return '/item/'

register(Item, ItemIndex)


# index.py
from pgindex import IndexBase, Vector

class ItemIndex(IndexBase):
    def get_description(self):
        return self.obj.content

    def get_data(self):
        return self.obj

    def get_vectors(self):
        return (
            Vector(self.obj.title, weight='A'),
            Vector(self.obj.content, weight='B'),
        )

To search simply use the pgindex.search method which returns a queryset from the pgindex.models.Index model:

from pgindex import search

index_queryset = search('foo')

See tests for examples.

pgindex.IndexBase methods

get_title()

This should return the title of the indexed object.

get_description()

This should return the description of the indexed object.

get_url()

This should return the url of the indexed object.

get_data()

You can return additional data that will be stored in the index field here, this value will be pickled and depickled.

get_published()

If this returns False and index will not be created

get_start_publish()

Can return a datetime.datetime which is the time when the index will be used. Returning None means that it will always be used.

get_end_publish()

Can return a datetime.datetime which is the time for the index expiration. Returning None means that it will never expire.

get_vectors()

This method needs to return a list or tuple of pgindex.Vector instances. This in turn is the base for the text search column.

Subscribe to package updates

Last updated Aug 10th, 2011

Download Stats

Last month:5

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.