diff --git a/media/forms.py b/media/forms.py index 6445566..c4aba67 100644 --- a/media/forms.py +++ b/media/forms.py @@ -108,7 +108,9 @@ class MediaAdminForm(ModelForm): data.setdefault("authors", []) data.setdefault("image", "") 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["authors"] = \ list(Auteur.objects.get_or_create(name=author_name)[0] for author_name in data["authors"])