Package: django-haystackbrowser
Author:Keryn KnightReleaseStatusstable (0.6.3)masterSectionsIn briefWhy I wrote itRequirements and dependenciesSupported versionsWhat it doesList viewStored data viewInstallationUsing pipUsing git directlyUsageExtending admin changeformsContributingContributorsTODOKnown issuesThe licenseIn briefA plug-and-playDjangoapplication for viewing, browsing and debugging data
discovered in yourHaystackSearch Indexes.Why I wrote itI loveHaystackbut I’m sometimes not sure what data I have in it. When a
query isn’t producing the result I’d expect, debugging it traditionally involves
using the PythonREPL to inspect the SearchQuerySet, and while I’m not allergic
to doing that, it can be inconvenient, and doesn’t scale well when you need to
make multiple changes.This application, a minor abuse of theDjango administration, aims to solve that
by providing a familiar interface in which to query and browse the data, in a
developer-friendly way.Requirements and dependenciesdjango-haystackbrowser should hopefully run on:Django 1.3.1or higher;Haystack 1.2or higher (including2.x)It additionally depends ondjango-classy-tags, though only to use the provided
template tags, which are entirely optional.Supported versionsIn theory, the below should work, based on a few minimal sanity-checking
tests; if any of them don’t, please open a ticket on theissue tracker.DjangoPython2.73.33.43.53.61.3.xYup1.4.xYup1.5.xYupYup1.6.xYupYupYup1.7.xYupYupYup1.8.xYupYupYupYup1.9.xYupYupYup1.10.xMaybeMaybeYupMaybe1.11.xMaybeMaybeYupMaybe2.0.xMaybeMaybeYupAny instances ofMaybeare because I haven’t personally used it on that,
version, nor have I had anyone report problems with it which would indicate a
lack of support.What it doesAny staff user with the correct permission (currently,request.user.is_superusermust beTrue) has a new application available in the standard admin index.There are two views, an overview for browsing and searching, and another for
inspecting the data found for an individual object.List viewThe default landing page, the list view, shows the following fields:model verbose name;theDjangoapp name, with a link to that admin page;theDjangomodel name, linking to the admin changelist for that model, if
it has been registered viaadmin.site.register;the database primary key for that object, linking to the admin change view for
that specific object, if the app and model are both registered viaadmin.site.register;Thescorefor the current query, as returned byHaystack- when no
query is given, the default score of1.0is used;The primary content field for each result;The first few words of that primary content field, or a relevant snippet
with highlights, if searching by keywords.It also allows you to perform searches against the index, optionally filtering
by specific models or faceted fields. That’s functionalityHaystackprovides
out of the box, so should be familiar.If yourHaystackconfiguration includes multiple connections, you can pick
and choose which one to use on a per-query basis.Stored data viewFrom the list view, clicking onView stored datafor any result will bring
up the stored data view, which is the most useful part of it.Shows allstoredfields defined in the SearchIndex, and their values;Highlights which of the stored fields is the primary content field
(usually,text);Shows all additional fields;Strips any HTML tags present in the raw data when displaying, with an
option to display raw data on hover.Shows anyHaystackspecific settings in the settings module.Shows up to5similar objects, if the backend supports it.The stored data view, like the list view, provides links to the relevant admin
pages for the app/model/instance if appropriate.InstallationIt’s taken many years ofmy lazinessto get around to it, but it is now
possible to get the package fromPyPI.Using pipThe best way to grab the package is usingpipto grab latest release fromPyPI:pip install django-haystackbrowser==0.6.3The alternative is to usepipto install the master branch ingit:pip install git+https://github.com/kezabelle/django-haystackbrowser.git#egg=django-haystackbrowserAny missing dependencies will be resolved bypipautomatically.If you want the last release (0.6.3), such as it is, you can do:pip install git+https://github.com/kezabelle/django-haystackbrowser.git@0.6.3#egg=django-haystackbrowserYou can find all previous releasestagged on GitHubUsing git directlyIf you’re not usingpip, you can get the latest version:git clone https://github.com/kezabelle/django-haystackbrowser.gitand then make sure thehaystackbrowserpackage is on your python path.UsageOnce it’s on your Python path, add it to your settings module:INSTALLED_APPS += (
    'haystackbrowser',
)It’s assumed that bothHaystackand theDjango administrationare already in yourINSTALLED_APPS, but if they’re not, they need to be, so go ahead and add
them:INSTALLED_APPS += (
    'django.contrib.admin',
    'haystack',
    'haystackbrowser',
)With therequirementsmet and theinstallationcomplete, the only thing that’s
left to do is sign in to the AdminSite, and verify the newSearch resultsapp
works.Extending admin changeformsAssuming it works, you can augment your existing ModelAdmins by using
(or copy-pasting from) the templates available:admin/haystackbrowser/change_form_with_link.htmladds a link
(alongside thehistoryandview on sitelinks) to the corresponding
stored data view for the current object.admin/haystackbrowser/change_form_with_data.htmldisplays all
the stored data for the current object, on the same screen, beneath the standardModelAdminsubmit row.Both templates play nicely with the standard admin pages, and both ensure
they call their{% block %}’s super context.Their simplest usage would be:class MyModelAdmin(admin.ModelAdmin):
    change_form_template = 'admin/haystackbrowser/change_form_with_data.html'Though if you’ve already changed your template, either via the aforementioned attribute or
via admin template discovery, you can easily take the minor changes from these listed
templates and adapt them for your own needs.NoteBoth the provided templates check that the given context haschange=Trueand access to theoriginalobject being edited, so nothing will appear on
the add screens.ContributingPlease do!The project is hosted onGitHubin thekezabelle/django-haystackbrowserrepository. The main/stable branch ismaster.Bug reports and feature requests can be filed on the repository’sissue tracker.If something can be discussed in 140 character chunks, there’s alsomy Twitter account.ContributorsThe following people have been of help, in some capacity.Ben Hastings, for testing it underDjango 1.4and subsequently forcing
me to stop it blowing up uncontrollably.David Novakovic, for getting it to at least work underGrappelli, and
fixing an omission in the setup script.Francois Lebel, for various fixes.Jussi Räsänen, for various fixes.Vadim Markovtsev, for minor fix related to Django 1.8+.Michaël Krens, for various fixes.Anton Shurashov, for fixes related to Django 2.0.TODOEnsure the new faceting features work as intended (the test database I
have doesn’treallycover enough, yet)Known issuesPrior toDjango1.7, the links to the app admin may not actually work,
because the linked app may not be mounted onto the AdminSite, but passing
pretty much anything to the AdminSite app_list urlpattern will result in
a valid URL. The other URLs should only ever work if they’re mounted, though.
Seeticket 21056for the change.The licenseIt’sFreeBSD. There’s aLICENSEfile in the root of the repository, and
any downloads.Copyright (c) 2012, Keryn Knight
All rights reserved.Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.