Title: Accessing model instances associated with a forms.ModelMultipleChoiceField from the templates
Tags: django;django-models;django-forms;django-templates
Question: I'd like to create a form that would allow a visitor to pick one or several instances of a Model which roughly looks like this:

```class Package(models.Model):                                                                                                                     
    name = models.CharField(max_length=255)
    image = models.ImageField(upload_to="foo")
```

I have for that created a Form that looks like this:

```class PackageSelectionForm(forms.Form):
    packages = forms.ModelMultipleChoiceField(queryset=Package.objects.all(), widget=forms.CheckboxSelectMultiple())
```

Now, I'd like to display the image associated with each Package instance in the HTML form in their respective label tags (or near), but I can't manage to find a way to access the instances from the form fields.

Do you see how I can?

thanks

Comment: Thanks, I will check it out!

Comment: I wanted to do something similar, so I ended up creating a custom form field that lets you assign multiple fields from your model as html data attributes. You can check it out and pip install it if you think it will fit your needs: https://github.com/denvaar/django-fancy-feast/blob/master/docs/DataModelChoiceField.rst



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:09/07/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<django><django-models><django-forms><django-templates>', 'Title': 'Accessing model instances associated with a forms.ModelMultipleChoiceField from the templates', 'ViewCount': 90, 'id': 39374324, 'user_AboutMe': None, 'user_AccountId': 1514433.0, 'user_DisplayName': 'user1415785', 'user_Reputation': 315.0, 'user_Views': 28.0, 'user_id': 1415785.0}}