Skip to content

Instantly share code, notes, and snippets.

@baxeico
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baxeico/e5083af4fef6a968dc0d to your computer and use it in GitHub Desktop.
Save baxeico/e5083af4fef6a968dc0d to your computer and use it in GitHub Desktop.
User profile ModelForm with a custom group field
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