Last active
August 29, 2015 14:06
-
-
Save baxeico/e5083af4fef6a968dc0d to your computer and use it in GitHub Desktop.
User profile ModelForm with a custom group field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.contrib.auth.models import User, Group | |
class UserProfileForm(forms.ModelForm): | |
group = forms.ModelChoiceField(queryset=Group.objects.all(), | |
required=True) | |
class Meta: | |
model = User | |
fields = ['first_name', 'last_name', 'email', 'group'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment