Skip to main content

Django-Whoosh search engine

Djoosh is a very simple search engine for your Django projects.

WARNING: This is currently under heavy development, so use at your work risk!

Installation

  1. Install with pip:

    pip install djoosh

  2. Add djoosh to INSTALLED_APPS in your settings.py:

    INSTALLED_APPS = (
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            ...
            'djoosh',
    )
  3. In your models.py add:

    from djoosh import SearchMixin
    
    ...
    
    class BlogPost(models.Model, SearchMixin):
            ...

    Note SearchMixin in the parents for MyModel. Just add it to any model that you want to search.

  4. When you’re done, run python manage.py search rebuild

  5. That’s it! You can now search your blog posts using BlogPost.search.query('some query'),

    For example you can create a view like this:

    def search(request):
    
            query = request.GET.get('q', '')
    
            posts = BlogPost.search.query(query)
    
            return render_to_response('search_posts.html',
                                      {'posts': posts, 'query': query})

    … and your template can be:

    <form action="/search" method="get">
            <input type="text" name="q" value="{{ query }}" />
            <input type="submit" value="Search Blogs" />
    </form>
    
    <h1>Search Results</h1>
    {% for post in posts %}
            <h2>{{ post.title }}</h2>
            <p>{{ post.content }}</p>
    {% endfor %}

Fine-Tuning

Coming soon…

For the impatient:

blog/search.py:

from blog import BlogPost
from djoosh import site, SearchModel

class BlogPostSearch(SearchModel):
        model = BlogPost
        fields = ('title', 'tags')
        keywords = ('tags',)
        pk = 'id'

site.register(BlogPost, BlogPostSearch)

You may also have a look at djoosh.loading, particularly site and SearchModel.

Metadata

Release files for djoosh 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djoosh 0.1
File Size Uploaded Provenance Actions
djoosh-0.1.tar.gz 4.2 kB Without provenance Details for djoosh-0.1.tar.gz

Release files / djoosh-0.1.tar.gz

Download URL djoosh-0.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f5e1edbd0cbab0f9788c6074a11d23707722e59341184efcc86cc458a1f45aa
BLAKE2b-256 checksum
How to use checksums
6675202745c62d0d42f522912f260ace523998281926f184ff99b6f4401814bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for djoosh 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page