Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8171821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:34:56+00:00 2026-06-06T21:34:56+00:00

My views.py code: from django.template import Context, loader, RequestContext from django.http import HttpResponse from

  • 0

My views.py code:

from django.template import Context, loader, RequestContext
from django.http import HttpResponse
from skey import find_root_tags, count, sorting_list
from search.models import Keywords

def front_page(request):

    if request.method == 'get' :
        str1 = request.getvalue['word'] 
        fo = open("xml.txt","r")
        for i in range(count.__len__()):

            file = fo.readline()
            file = file.rstrip('\n')
            find_root_tags(file,str1,i)    

            list.append((file,count[i]))

            sorting_list(list)

        for name, count in list:
            s = Keywords(file_name=name,frequency_count=count)
            s.save()

        fo.close()
        return HttpResponseRedirect('/results/')

    else :  
        str1 = ''
        list = []
        template = loader.get_template('search/front_page.html')
        c = RequestContext(request)
        response = template.render(c)
        return HttpResponse(response)

def results(request):

    list1 = Keywords.objects.all()
    t = loader.get_template('search/results.html')
    c = Context({'list1':list1,
    })

    return HttpResponse(t.render(c))

@this for everyone.

the flow is this:

1) I run my app on the server .

2)It shows me the search page due to the else part of the view “def front_page(request)”, now I want to execute the if part of the view “def front_page(request)” because I want to execute my python code written there and the redirected to the view “def results(request)”, how can I do that ?

3) what should I mention in “action” of the front_page.html and in urls.py so that I can get back to the same view again. because I could’nt get back to the same view that I want it is repetitively showing me the same search page.Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:34:57+00:00Added an answer on June 6, 2026 at 9:34 pm

    To enlarge upon the answer posted by @Barnaby….by using action=’#’ your form will be posted to the same url as the url used in the get request for the form.
    Then in your view code, you have logic that says – if the request for this url is a GET request then do the work to configure the form, otherwise, you assume it is a POST and then you can handle the response.

    Additionally I would advise that the your view explicitly checks that the request is a POST and if not make the assumption that it is a GET, rather than the other way around (as you have it), this is safer, as GET and POST are not the only request types, and you definitely need to know that you are dealing with a POST request if you want to deal with variables submitted in the POST request.

    Hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my views.py file code: #!/usr/bin/python from django.template import loader, RequestContext from django.http import HttpResponse
My views.py file code: #!/usr/bin/python from django.template import loader, RequestContext from django.http import HttpResponse
this my middleware code : from django.conf import settings from django.template import RequestContext class
here is my code: urls.py: from django.conf.urls import patterns from views import show,showpage urlpatterns
my views.py : from django.core.context_processors import csrf from django.views.decorators.csrf import csrf_protect from django.http import
Here's the code for my view.py file: from django import forms def student(request): id
I have a view login() : from django.http import HttpRequest from useraccounts.models import BadIP
from django.utils.simplejson import dumps, loads # -*- coding: utf-8 -*- def index(request): return render_to_response('test2/index.html')
I'm new to Django and Python. When I move my code from my local
I have to change the is_staff option from views.py file to disabling the Django-admin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.