By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

why UnboundLocalError occure

P: 2
def post_edit(request,pk):
post =get_object_or_404(Post, pk=pk)
if request.method=="POST":
form=PostForm(request.POST,instance=post)
if form.is_valid():
post=form.save(commit=False)
post.author= request.user
post.published_date=timezone.now()
post.save()
return redirect('post_detail',pk=post.pk)
else:
form = PostForm(instance=post)
return render (request,'blog/post_edit.html',{'form':form})
Oct 28 '17 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.