run black, add a try/catch around the formcopy fix
This commit is contained in:
parent
0941c50c69
commit
51e16fba97
@ -176,8 +176,18 @@ class EditBook(View):
|
|||||||
# we have to make sure the dates are passed in as datetime, they're currently a string
|
# we have to make sure the dates are passed in as datetime, they're currently a string
|
||||||
# QueryDicts are immutable, we need to copy
|
# QueryDicts are immutable, we need to copy
|
||||||
formcopy = data["form"].data.copy()
|
formcopy = data["form"].data.copy()
|
||||||
formcopy["first_published_date"] = datetime.strptime(formcopy["first_published_date"], "%Y-%m-%d")
|
try:
|
||||||
formcopy["published_date"] = datetime.strptime(formcopy["published_date"], "%Y-%m-%d")
|
formcopy["first_published_date"] = datetime.strptime(
|
||||||
|
formcopy["first_published_date"], "%Y-%m-%d"
|
||||||
|
)
|
||||||
|
except MultiValueDictKeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
formcopy["published_date"] = datetime.strptime(
|
||||||
|
formcopy["published_date"], "%Y-%m-%d"
|
||||||
|
)
|
||||||
|
except MultiValueDictKeyError:
|
||||||
|
pass
|
||||||
data["form"].data = formcopy
|
data["form"].data = formcopy
|
||||||
return TemplateResponse(request, "book/edit_book.html", data)
|
return TemplateResponse(request, "book/edit_book.html", data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user