如果这与这两个应用程序无关,我深表歉意。以下代码段将向我抛出“一旦获取切片就无法过滤查询”:
模型.py
class Cartao(models.Model):
...
user = models.ForeignKey(settings.AUTH_USER_MODEL)
tags = TaggableManager()
autocomplete_light_registry.py
import autocomplete_light
from taggit.models import Tag
class TagAutocomplete(autocomplete_light.AutocompleteModelBase):
autocomplete_js_attributes={'placeholder': 'Ex: pessoal, serviços',}
def choices_for_request(self):
choices = super(TagAutocomplete, self).choices_for_request()
return choices.filter(cartao__user=self.request.user)
autocomplete_light.register(Tag, TagAutocomplete)