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

发布于 2024-08-20 10:25:56 字数 1509 浏览 5 评论 0原文

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管理.py同步数据库”时,

它打印:

  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?

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,
        }
    )

when i 'python manage.py syncdb'

it print :

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

what is the SeparatedValuesField ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼眸 2024-08-27 10:25:56

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

该博客目前似乎无法使用,但也许作者之前已经提到或使用过此片段。

It seems to be a user-defined custom form field, one possible definition is on Django Snippets: http://www.djangosnippets.org/snippets/497/

The blog doesn't seem to be available right now, but perhaps the author has mentioned or used this snippet previously.

浴红衣 2024-08-27 10:25:56

Google 发现来自同一(非- 此处响应)博客。

Google finds this page, from the same (non-responsive here) blog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文