79540757

Date: 2025-03-28 07:20:23
Score: 0.5
Natty:
Report link

The common approach is to simply return the options as an html snippet (which htmx expects). So, you may have a partial like
`partials/select.html`:

```{% for option in options %}
<option value="{{option.value}}">{{option.label}}</option>
{% endfor %}
```
Then your `LookupView` can return it with the options you filter based on the value you get after submitting:

```
LookupView(View):
def get(self, request, *args, **kwargs) ...
options = your_filtered_values here # maybe a queryset from the database?
response = render(request," partials/select.html", dict(options=options))
# set response headers to control where and how to place the returned template
response["Hx-Retarget"] = "css_selector_of_the_target"
response["Hx-Reswap"] = "innerHTML"
return response
```

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
Posted by: McPherson