4 ms·
In the example where does the account variable come from in the form_valid method? def form_valid(self, form): send_activation_email(self.request.user
by Siecje 13y ago
In the example where does the account variable come from in the form_valid method?
def form_valid(self, form):
send_activation_email(self.request.user)
account = form.save()
- tomchristie 13y agoHiya, I think you've misread the example. The `account` variable doesn't come from anywhere outside the method. It's being instantiated right there.
- damon_c 13y agoIf you look further down: http://django-vanilla-views.org/#inheritance-hierachy-django-style http://django-vanilla-views.org/#inheritance-hierachy-django... It looks like that view which is a "CreateView" uses a ModelForm as its form. ModelForm's save methods return an instance of their Model. In this case, account is the instance of the Account model which is created when that form is saved. Edit - Here's the relevant Django doc: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method https://docs.djangoproject.com/en/dev/topics/forms/modelform...