Reputation: 465
Code I'm working with:
class Foo(View):
def post(self, request):
form_data = {
'form': UserRegistrationForm(request.POST),
'sex': request.POST['sex'],
'terms': request.POST['terms'],
}
if form_data['form'].is_valid():
user = form_data['form'].save(commit=False)
user.is_active = False
user.save()
user.profile.sex = from_data['sex'] #raise err here
user.profile.save()
This throws name 'from_data' is not defined.
Its weired for me, it doesn't work, and this does:
user.profile.sex = request.POST['sex']
For someone who was used to code in C that situation is little funny and much annoying.
Upvotes: 0
Views: 65
Reputation: 320
from_data['sex']
should be changed to
form_data['sex']
Just a minor typo it seems.
Hope that helps
Upvotes: 1