Modified files
app/views.py
---
+++
@@ -1,3 +1,5 @@
+from django.forms.models import BaseModelForm
+from django.http import HttpResponse
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views.generic import (
@@ -22,6 +24,10 @@
fields = ["title", "status", "content", "twitter_post"]
success_url = reverse_lazy("home")
+ def form_valid(self, form: BaseModelForm) -> HttpResponse:
+ form.instance.creator = self.request.user
+ return super().form_valid(form)
+
class ArticleUpdateView(UpdateView):
template_name = "app/article_update.html"