[Answered ]-Django forms – dictionary and lists

2👍

The form.cleaned_data dictionary is flat. You can take that and create whatever data structure you want.

cleaned_data = form.cleaned_data
nested_data = {
    'name': cleaned_data['name'],
    ...
    'user': {
        'username': cleaned_data['username'],
        'password': cleaned_data['password'],
    }
}

Leave a comment