Eu tenho esse modelo do Django:
class Profile(User):
rg = models.CharField(max_length=20, null=True,blank=True)
cpf = models.CharField(max_length=15, unique=True, null=True)
about = models.TextField(_('about'),max_length = 10000, null=True, blank=True)
knowledge = models.ManyToManyField(SubCategory, related_name="profile_knowledge")
class Meta:
verbose_name = _('profile')
verbose_name_plural = _('profiles')
db_table = 'pd_profile'
permissions = (
("view_all_users", "Can view user details"),
("edit_all_users", "Can edit user details"),
("search_profile", "Can search talents"),
("user_config", "Can access user config page "),
("add_users_permissions", "Can add global permissions to user"),
("export_user_data", _("Can export users data")),
)
def __str__(self):
return self.full_name
E eu quero fazer uma query pelos Perfis dessa maneira:
query = SearchQuerySet().all().models(Profile)
t = query.filter(content=data.get('value'))
if not t:
suggestion = query.spelling_suggestion(data.get('value'))
t = query.filter(content=suggestion)
query = t
query = query.order_by("full_name")
Meu problema é que não retorna em ordem alfabética de jeito nenhum.. To fazendo algo errado? Valeu!
django-haystack==2.5.0 djangorestframework==3.3.2 elasticsearch==1.5.2