👉

Did you like how we did? Rate your experience!

Rated 4.5 out of 5 stars by our customers 561

Award-winning PDF software

review-platform review-platform review-platform review-platform review-platform

Video instructions and help with filling out and completing Which Form 8655 Blog

Instructions and Help about Which Form 8655 Blog

In this video, I'm going to build everything needed to create new blog posts on the website. The only thing that users will need is to be authenticated. If you're authenticated, you'll be able to create blog posts. Just like when we built our user account, we wanted to create or register new users. We're going to build a forum for creating new blog posts. I'm right-clicking on "blog" and creating a new file. I'm going to press "Ctrl + S" and I'm going to name this file "forms.py". Inside here, we need to do "from Django import forms" and "from blog models import BlogPost" model. Now, I want to create the form, so I'm going to go to class. I'm going to name it "CreateBlogPostForm" and it's going to extend the "forms.ModelForm". I need to do "class Meta" to tell it what model the form should follow, so that's going to be the "BlogPost" model. The fields that we're interested in are the title field, body field, and the image field. These are the only things that users can actually change. If we look at the model, we have all these fields. The only ones that the user can actually set themselves are the title, body, and image. The others will be set automatically or through some function or process. I'm pressing "Ctrl + S" to save that. Next, I'll work on the view. I'm going to go into "views.py" inside our "blog" app. Let's work on our "create_blog" view first. I'll set a context variable as we always do. Next, I'll set a user variable, so "user = request.user". Now, if the user is not authenticated, I want to return redirect to a page that we are going to create later in this video named "must_authenticate". So, if a user...