django-haystack / django-haystack/django-haystack
Django SearchModelAdminMixin doesn't implement each_context
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
There is a method on Django's (1.8.2) AdminSite class called each_context which provides a context for each and every view in the Django admin. This features comes in handy when you're overriding admin templates and you want to make data (or whatever) globally available to your templates.
The changelist view-overriding that takes place in Haystack's SearchModelAdminMixin unfortunately doesn't call each_context, so any customization you do to each_context is lost when a search is submitted.
The recreate the issue:
- Implement a custom
AdminSiteobject ( https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#adminsite-objects ), and implement a customeach_contextmethod ( https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.AdminSite.each_context ) and spit out an extra context variable. - Override a globally used admin template (say, anything in
base.html) and include the extra context variable you added toeach_context. - Configure an admin using Haystack's
SearchModelAdmin.
4 Try to submit a search to your model's list view and note that your custom context variable is lost.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating SearchModelAdminMixin and its changelist override, then compare its context handling with Django 1.8 AdminSite.each_context. Reproduce the issue with a custom AdminSite and overridden admin template; done means the custom context variable remains available after submitting a search.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100