Hi everyone,

I'm stuck with the redirection in django.

This is my url.py

    (r'^article/(?P<id>\d+)/$', 'myapp.myappFront.views.article'),
    (r'^article/(?P<id>\d+)/addComment/$',
'myapp.myappFront.views.addComment'),

I developed a little view in order to add comment to my article, this is my
view.py

def article(request, id):
article = article.objects.get(id=id)
commentaires = Commentaire.objects.filter(article=article.id
).order_by("-dateComment")
#dateTime
date = datetime.datetime.now()

c = Context({
'article' : video,
'commentaires' : commentaires,
'now' : date,
})
        form = CommentForms()
        c['form'] = form
return render_to_response('myappFront/article.html', c,
context_instance=RequestContext(request))
def addComment(request, id):
    article = article.objects.get(id=id)
    if request.method == 'POST':
        form = CommentForms(data=request.POST)
        if form.is_valid():
            cf_comment = form.cleaned_data['cf_comment']
            cf_writer = request.user
            cf_date = datetime.datetime.now()
            cf_video = video
            c1 = Commentaire.objects.create(comment=cf_comment,
dateComment=cf_date, writer=cf_writer, video=cf_video)
            c1.save()
        else:
    c = Context({
        'id' : id,
    })
    #return render_to_response('myappFront/article.html', c,
context_instance=RequestContext(request))
    #return HttpResponseRedirect(reverse('myappFront.views.article',
args=(id,)))
    #return HttpResponseRedirect(reverse('myappFront.views.article',
kwargs={'id': id}))
    return HttpResponseRedirect(reverse('myappFront.views.article',
args=(id,)))

The view article works well, my form for add comment seems ok, i can add
comment to my article, but the problem is
the redirection at the end of the addComment method.
As u see, I tried many many syntax in order to redirect the user to the
article, but all of this test failed.
Every time i have this kind of error :

NoReverseMatch at /article/9/addComment/
Reverse for 'myAppFront.views.article' with arguments '(u'9',)' and keyword
arguments '{}' not found.

Any idea ?

Thx for all :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to