Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Use setdefault
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Aug 19, 2020
1 parent ae99e6a commit c2d2881
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions default/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ def uploadfile(request):
else:
data_file.write(request_file)

if 'files' not in request.session:
request.session['files'] = []
request.session['files'].append(data_file.as_dict())
request.session.setdefault('files', []).append(data_file.as_dict())
# https://docs.djangoproject.com/en/2.2/topics/http/sessions/#when-sessions-are-saved
request.session.modified = True

Expand Down

0 comments on commit c2d2881

Please sign in to comment.