I have a need to add a customized page to django admin.
Thus I used TemplateView and passed a list of models to the template.
Here’s the model
class Event(models.Model):
title = models.CharField()
status = models.CharField()
receiver = models.ForeignKey()
topic = models.ForeignKey()
data = JSONField()
...
I show the list of items in and tags.
<select name="events" id="events">
{% for n in events %}
<option value="{{ forloop.counter0 }}">{{ n.pk }} - {{ n.title }}</option>
{% endfor %}
</select>
And when the user selects an item from the list, I want to show more details of the selected item - status
, receiver
, topic
, data
, etc.
I don’t think i need to make a request to pull the data since I already pulled it on page load.
I can get index of selected item, thus I think I can get data in javascript.
I know how to write custom template filters to get data from list by index.
But now sure how I can get that events
data in javascript.
Javascript code with this situation would be helpful.
Thanks