Hi cha,
Programming in django is just programming in python. Views are just
normal python functions that are called from urls.py which contains
pattern which is also a function.
If you want both views in one file, do exactly that. You could cut and
paste the view in the second app and paste it in the first apps view
then adjust the pattern in your urls.py file.
Or better still you could create a new file and cut and paste the
functions in the first and second view into that new file and make the
adjustment in your urls.py file.
If you still don't understand the explanation you could copy and paste
the your urls file here or someone might be able to provide a link to
some resource on the web.
You need to be comfortable with programming with python for you to get
the hang of django.

On 9/11/11, cha <mohamma...@gmail.com> wrote:
> 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.
>
>

-- 
Sent from my mobile device

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