django-haystack / django-haystack/django-haystack
Allow custom context when using a template for fields
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
An idea for a new feature - please redirect me if an issue for this already exists.
It would be useful if SearchField had a get_context_data() method (or similar) that returns the context passed to the template when using use_template=True on a field.
This could then be overridden to provide extra stuff in the context.
For the application I am currently working on we need to get some related objects that cannot be accessed directly in template (a reverse foreign key lookup and a filter() on the resulting QuerySet). I haven't found a clean way of doing this, so we've had to stop using templates for now.
Looking through the source it should be a trivial feature to add, so I am happy to create a PR if anyone likes the idea.
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 at SearchField and the use_template=True path to inspect how template context is currently assembled. The feature is done when the context can be provided or extended through an overridable get_context_data()-style method, allowing related objects and filtered query results to reach the template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100