Better publish date

This commit is contained in:
Yohann D'ANELLO 2020-10-03 15:55:56 +02:00
parent dcba832549
commit 9dd2a142b7
1 changed files with 3 additions and 1 deletions

View File

@ -108,7 +108,9 @@ class MediaAdminForm(ModelForm):
data.setdefault("authors", []) data.setdefault("authors", [])
data.setdefault("image", "") data.setdefault("image", "")
self.cleaned_data["title"] = data["title"] self.cleaned_data["title"] = data["title"]
self.cleaned_data["published_date"] = data["date_published"][:10] self.cleaned_data["publish_date"] = data["date_published"][:10]
while len(self.cleaned_data["publish_date"]) == 4 or len(self.cleaned_data["publish_date"]) == 7:
self.cleaned_data["publish_date"] += "-01"
self.cleaned_data["number_of_pages"] = data["pages"] self.cleaned_data["number_of_pages"] = data["pages"]
self.cleaned_data["authors"] = \ self.cleaned_data["authors"] = \
list(Auteur.objects.get_or_create(name=author_name)[0] for author_name in data["authors"]) list(Auteur.objects.get_or_create(name=author_name)[0] for author_name in data["authors"])