2010-01-31 45 views
1
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, 
     } 
    ) 

當我蟒蛇manage.py執行syncdb「哪裏是SeparatedValuesField在我的代碼,我使用的獅身人面像

它打印:

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?

回答

0

這似乎是一個用戶自定義的表單字段,一個可能的定義是Django的片段:http://www.djangosnippets.org/snippets/497/

的博客似乎沒有可用的權利,但也許是筆者提及或使用該以前的片段。

0

Google發現this page,來自同一個(無響應的)博客。