Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:38:59+00:00 2026-06-12T22:38:59+00:00

Using the django-haystack and solr as a search engine, I have successfully implemented a

  • 0

Using the django-haystack and solr as a search engine, I have successfully implemented a search engine which throws out the list of users whose usernames, first names, last names, or email addresses match the given query.

search_indexes.py

from haystack.indexes import *
from haystack import site

from django.contrib.auth.models import User

class UserIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    first_name = CharField(model_attr='first_name')
    last_name = CharField(model_attr='last_name')
    email = CharField(model_attr='email')

    def index_queryset(self):
        return User.objects.exclude(username='root')

site.register(User, UserIndex)

and

user_text.txt

{{ object.username }}
{{ object.first_name }}
{{ object.last_name }}
{{ object.email }}

However, I am planning to let the users set their privacy settings so that they will not be searchable with their first_name, last_name, or email address.

I have been banging my head and my computer for days trying to accomplish this functionality but haven’t found any real good solution yet.

Is it at all possible to accomplish the above functionality?

Thank you very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:39:01+00:00Added an answer on June 12, 2026 at 10:39 pm

    You can create a constraints table and e.g. use haystack’s SearchQuerySet to exclude upon. Here’s an example using tastypie as an API, but this might as well be your custom service or view layer.

    http://django-tastypie.readthedocs.org/en/latest/resources.html#advanced-filtering

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding search to an existing Django site, using Haystack with a Solr backend.
Hi I´m using django with haystack search. I have one model for Events. Thats
I am using django haystack with xapian as the backend search engine. I am
i have problem with results in django-cms and haystack search. I'm using django-cms-search plugin,
Im using haystack to search my django website, it does this perfectly. However on
I'm using django-haystack for a search page on my site. I'm basically done, but
I have a model with an ImageField that I'm indexing for search using Django
I am using django-haystack for search. By default it is showing oldest objects first
I am using django-haystack with solr backend. I've saved three songs in model. When
I've recently set up solr and haystack to search one of my django models.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.