class AddNews(CreateView):
form_class = AddNewsForm
template_name = 'news/add_news.html'
def get_success_url(self, *args, **kwargs):
return reverse_lazy('profiles:profile', kwargs={"slug": self.request.user.username})
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs.update({'initial': {
'author ': self.request.user,
}
})
return kwargs