How to create tuple from Django model for choosing in form

For records user management I need create choose tuple:

userslib = User.objects.all()
user_choose_list = []
for user in userslib:
    user_choose_list.append((user.id, user.username))
    user_choose = tuple(user_choose_list)

Then add an object to model:

work_user = models.IntegerField(choices=user_choose, default=0, null=True)

 

See also  ToDo list functionality for my Work Accounting Project
Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *