def itemconfirmation(request, pk):
item = Food_item.objects.get(id=pk)
userobj = request.user
user = UserProfile.objects.get(user=userobj)
if request.method == 'POST':
count_form = CountForm(data=request.POST)
if count_form.is_valid():
countform = count_form.save(commit=False)
countform.useradno = user.adno
countform.itemid = item.id
countform.save()
c = RequestContext(request, {
'item': item, 'count_form': count_form
})
return render_to_response('itemconfirmation.html', context_instance=c)
I have a view defined like this. I'm getting error in making the user object extended to UserProfile and cannot user the user.id