Hello, I've searched similar topics but haven't found what I need..
I extended Users model with UserAttributes model, some additional fields added and etc.. now I'm trying to make ModelForm out this.. so I have a little problem in here..
I WANT TO list groups as a ChoiceField not a MultipleChoiceField.. It's a requirement by specification so it must be so.
so here's the code..
from django.forms import ModelForm
from django.contrib.auth.models import User
from helpdesk.models.userattributes import *
from django.utils.translation import ugettext as _
class SettingsOperatorsForm(ModelForm):
groups = forms.ChoiceField(
label=_(u'Rights'),
required=True,
choices=["what's in here?"]
)
class Meta:
model = UserAttributes
fields = ('first_name', 'last_name', 'job_title', 'email', 'password', 'is_active', 'groups' )
there's auth_group table in database, so i tried to make it like this , but I've got a no form displayed at all:
from django.contrib.auth.models import User, Group
groups = forms.ChoiceField(
label=_(u'Rights'),
required=True,
choices=Group.objects.all()
)
I think it's better would be just to convert multipleChoiceField to ChoiceField
in plain talk:
should become just SELECT box.