class CreateArticle(LoginRequiredMixin, CreateView):
    model = Article

def form_valid(self, form):
    form.instance.author = self.request.user
return super(CreateArticle, self).form_valid(form)
How to set ForeignKey in CreateView?