forms.py: used get_user_model() inside __init__ instead of User, to facilitate late binding, models.py: used settings.AUTH_USER_MODEL instead of user
This commit is contained in:
parent
6a78c3f8b0
commit
9bbc09dba8
2 changed files with 8 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
from django import forms
|
||||
from django.forms import ModelForm
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.contrib.auth.models import Group
|
||||
from todo.models import Item, List
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ class AddItemForm(ModelForm):
|
|||
super(AddItemForm, self).__init__(*args, **kwargs)
|
||||
# print dir(self.fields['list'])
|
||||
# print self.fields['list'].initial
|
||||
self.fields['assigned_to'].queryset = User.objects.filter(groups__in=[task_list.group])
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[task_list.group])
|
||||
self.fields['assigned_to'].label_from_instance = \
|
||||
lambda obj: "%s (%s)" % (obj.get_full_name(), obj.username)
|
||||
|
||||
|
@ -49,7 +49,7 @@ class EditItemForm(ModelForm):
|
|||
# must find other members of the groups the current list belongs to.
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditItemForm, self).__init__(*args, **kwargs)
|
||||
self.fields['assigned_to'].queryset = User.objects.filter(groups__in=[self.instance.list.group])
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[self.instance.list.group])
|
||||
|
||||
class Meta:
|
||||
model = Item
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue