I have a gadget in which users can log in, view their profile and follow each other. “Follow” is a relationship, like a regular “friend” relationship in virtual communities, but this is not necessarily reciprocal, which means that you can follow a user without requiring the user to follow the person who follows him. my problem: if I am a registered user and I go to profile X, and then click the button, how can I take the current profile ID? (The current profile means the profile that I, a registered user, are currently viewing.)
view:
def follow(request):
if request.method == 'POST':
form = FollowForm(request.POST)
if form.is_valid():
new_obj = form.save(commit=False)
new_obj.initiated_by = request.user
u = User.objects. what here?
new_obj.follow = u
new_obj.save()
return HttpResponseRedirect('.')
else:
form = FollowForm()
return render_to_response('followme/follow.html', {
'form': form,
},
context_instance=RequestContext(request))
early!