Store the id of the object in a manytomany field

0

I have a user model in django with a field:

wallets = models.ManyToManyField(Wallet)

and a Wallet object with other fields. I currently store the names of the Wallets objects assigned to the user in the user's wallets field. How can I store the id and that the name is still shown in the following form?

wallets = forms.ModelMultipleChoiceField(queryset=Wallet.objects.all(),to_field_name="name",required=False)

    
asked by XBoss 15.07.2018 в 15:26
source

1 answer

0

Apparently Django does it internally, so I have abstracted from the process and I can store objects with different names and treat them as if they were different.

    
answered by 15.07.2018 / 15:33
source