我的代码中的SeparatedValuesField在哪里,我使用了sphinx

时间:2010-01-31 10:26:02

标签: python django django-sphinx

from django.db import models
from djangosphinx import SphinxSearch

# A sample model from iBegin
class City(models.Model):
    name            = models.CharField(max_length=32)
    aliases         = SeparatedValuesField(blank=True, null=True)#<-------this
    slug            = models.SlugField(blank=True)
    country         = models.ForeignKey(Country)
    state           = models.ForeignKey(State, blank=True, null=True)
    listings        = models.PositiveIntegerField(editable=False, default=0)

    latitude        = models.DecimalField(max_digits=9, decimal_places=6, editable=False, default=0, blank=True)
    longitude       = models.DecimalField(max_digits=9, decimal_places=6, editable=False, default=0, blank=True)

    date_added      = CreatedDateTimeField(editable=False)
    date_changed    = ModifiedDateTimeField(editable=False)

    class Meta:
        unique_together = (('country', 'state', 'slug'), ('country', 'state', 'name'))
        db_table = 'cities'

    search = SphinxSearch(
        index='cities', # defaults to cities either way
        weights={ # individual field weighting, this is optional
            'name': 100,
            'aliases': 90,
        }
    )

当我'python manage.py syncdb'

打印:

  File "D:\zjm_code\sphinx_test\models.py", line 7, in City
    aliases         = SeparatedValuesField(blank=True, null=True)
NameError: name 'SeparatedValuesField' is not defined

SeparatedValuesField是什么?

2 个答案:

答案 0 :(得分:0)

Google从同一个(此处无响应)博客中找到this page

答案 1 :(得分:0)

它似乎是一个用户定义的自定义表单字段,一个可能的定义是在Django Snippets上:http://www.djangosnippets.org/snippets/497/

博客目前似乎无法使用,但也许作者之前曾提及或使用此代码段。