Quiz: Edit Listing Page
Test your knowledge of creating the Editing Listing page.
1
Refer to the following code.
def edit_post(request, detail_id):
post = Posts.objects.get(id=detail_id)
if request.method != 'POST':
form = PostForm(instance=post)
else:
form = PostForm(request.POST, request.FILES, instance=post)
if form.is_valid():
form.save()
return redirect('posts:all_posts')
context = {'post': post, 'form': form}
return render(request, 'posts/edit_post.html', context)
The line post = Posts.objects.get(id=detail_id)
retrieves a particular post.
A)
True
B)
False
Question 1 of 60 attempted
Get hands-on with 1400+ tech skills courses.