If I understand your need correctly, you can do something like:
<form method="POST"> <select name="item_id"> {% for entry in items %} <option value="{{ entry.id }}">{{ entry.name }}</option> {% endfor %} </select> </form>
By the way, you should specify name elements instead of item, since this is a collection (but this is just a note;)).
This way you will have a list of all the items in the database.
Then, in the message, here is what you need to do:
def selectview(request): item = Item.objects.all()
Of course, be sure to include get_object_or_404
source share