1

I have this Model

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

And I Want to do a query through this Profiles like that:

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")

My problem is, the order_by simples doesn't work... My query should return in alphabetical order but it doesn't. Am I doing something wrong? Thanks

django-haystack==2.5.0 djangorestframework==3.3.2 elasticsearch==1.5.2

1 Answers1

0

I did solve the problem by adding the field in search_indexes.py like that full_name = indexes.CharField(model_attr='full_name', indexed=False, stored=True)

Than I did a rebuild_index and it worked like a charm.. Thanks anyway.