Scenario:
I have a field named "editor" in my model "Questions" as below:
CHOICE_LIST = (('0', 'Undefined'), ('staffGroup', 'staffGroup'), ('staffGroup02', 'staffGroup02'), ('staffGroup03', 'staffGroup03'), ('staffGroup04', 'staffGroup04'), ('staffGroup05', 'staffGroup05'),)
editor = models.CharField(max_length=350, default=0, choices=CHOICE_LIST, verbose_name='Responsibility')
the editor field has a choice list which I manually defined from the names of user groups.
Problem:
- How can I generate the list directly from the auth_grup table?
- How can I selectedly do that (as I may not need all of them, I only may need those groups which starts with 'staff' string)
- How can I make this list static (so deleting an entry from usergroup may not delete it from the list) or dynamic (will dynamically update the list with the change in auth_group table)?