Hello all I have two views in two app and I want to get them in main
url file how I Can do that ?

first view in project/app_news/views.py

def article_index(request):
        return render_to_response('news/index.html', {
            'news_slide':  Article.objects.filter(status=1,
statusslide=1)[:6],
            'section_list' : Section.objects.all(),
            'last_lib' : Library.objects.all()[:3],
},
            context_instance=RequestContext(request)
)

secend view in project/app_poll/views.py

def questionlast(request):
    try:
        question = Question.objects.order_by('id').reverse()[0]
    except ObjectDoesNotExist, e:
        raise Http404
    if request.method == 'POST':
        try:
            last_choice_id = request.session[question.id]
            last_choice = Choice.objects.get(id = last_choice_id)
            last_choice.total_votes -= 1
            last_choice.save()
        except KeyError, e:
            pass
        choice_id = int(request.POST['choices'])
        choice = Choice.objects.get(id = choice_id)
        choice.total_votes += 1
        choice.save()
        request.session[question.id] = choice.id
        return HttpResponseRedirect(question.get_results_url())
    if request.method == 'GET':
        try:
            last_choice_id = request.session[question.id]
            last_choice = Choice.objects.get(id = last_choice_id)
        except KeyError, e:
            last_choice = 0
        choices = Choice.objects.filter(question = question)
        payload = {'question':question, 'choices':choices,
'last_choice':last_choice}

        return render('news/index.html', payload, request)

I want get both views in one template In news/index.html IWant get
poll in index page

-- 
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