class UserCreateView(AdminCreateView):
model=User
success_url='/portal/accounts/list'
form_class=PortalUserForm
def get_form_kwargs(self):
kwargs = super(UserCreateView, self).get_form_kwargs()
kwargs.update({'request' : self.request})
return kwargs
def get_initial(self):
return {}
On a ModelForm (unrelated to the form/model above) I was trying to access the self.initial for a particular field, which threw a Key exception. The initial dictionary passed down on the yellow screen did not match the form or data for the view at all.
kwargs:
I have no idea where that initial dictionary came from. My get_form_kwargs looks like this:
def get_form_kwargs(self):
kwargs = super(PendingLabelsCreateView, self).get_form_kwargs()
kwargs.update({'user': self.request.user})
return kwargs
The direct ancestor doesn;'t have get_form_kwargs defined, and that is defined as such:
class AdminCreateView(LoginRequiredMixin, UserPassesTestMixin, CreateView):
I need to understand where that initial value came from and determine if I have static values where I don't want them.
Thanks in advance
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/db24def3-f8cc-4954-bbd3-72b6ed3fa0d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment