i have a Reply class:
class Reply(models.Model):
reply_to = models.ForeignKey(New)
creator = models.ForeignKey(User)
reply = models.CharField(max_length=140,blank=False)
a replay form:
class ReplyForm(ModelForm):
class Meta:
model = Reply
fields = ['reply']
where New is the Post class (containing users posts) and a view
def save_reply(request):
#u = New.objects.get(pk=id)
if request.method == 'POST':
form = ReplyForm(request.POST)
if form.is_valid():
new_obj = form.save(commit=False)
new_obj.creator = request.user
new_obj.reply_to = form.reply_to
# reply_to_id = u
new_post = New(2) #this works hardcoded, but how can i get the blog New post #id, as a parameter, instead?
new_obj.reply_to = new_post
new_obj.save()
return HttpResponseRedirect('.')
else:
form = ReplyForm()
return render_to_response('replies/replies.html', {
'form': form,
},
context_instance=RequestContext(request))
where created_by belongs to New class and represents the creator of the post (which is to be replied)
how can i assign the current post to the reply under it?
thanks in advance!