def post(self, request): form = forms.PostForm(request.POST, request.FILES) if form.is_valid(): newpost = form.save(commit=False) newpost.user = request.user newpost.save() return redirect('/home')
def post(self, request): form = forms.PostForm(request.POST, request.FILES) if form.is_valid(): # creating django like model without saving to database post = form.save(commit=False) post.user = request.user post.save() return redirect('/home/')
def post(self, request): form = forms.PostForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() return redirect('/home/')
def get_context_data(self, *args, **kwargs): data = super().get_context_data(*args, **kwargs) data['post_form'] = forms.PostForm() return data