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 9148393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:15:38+00:00 2026-06-17T11:15:38+00:00

I am creating a list from some of the model data but I am

  • 0

I am creating a list from some of the model data but I am not doing it correctly, it works but when I refresh the page in the broswer reportResults just gets added to. I hoped it would get garbage collected between requests but obviously I am doing something wrong, any ideas anyone??

Thanks,
Ewan

reportResults = []   #the list that doesn't get collected
def addReportResult(fix,description):  
    fix.description = description
    reportResults.append(fix)

def unitHistory(request,unitid, syear, smonth, sday, shour, fyear, fmonth, fday, fhour, type=None):
   waypoints = Fixes.objects.filter(name=(unitid))
    waypoints = waypoints.filter(gpstime__range=(awareStartTime, awareEndTime)).order_by('gpstime')[:1000]
    if waypoints:
        for index in range(len(waypoints)): 
...do stuff here selecting some waypoints and generating "description" text
                    addReportResult(waypointsindex,description) ##append the list with this, adding a text description

    return render_to_response('unitHistory.html', {'fixes': reportResults})   
  • 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-17T11:15:40+00:00Added an answer on June 17, 2026 at 11:15 am

    Just so you’re aware of the life cycle of requests, mod_wsgi will keep a process open to service multiple requests. That process gets recycled every so often but it is definitely not bound to a single request as you’ve assumed.

    That means you need a local list. I would suggest moving the addReportResult function contents directly in-line, but that’s not a great idea if it needs to be reusable or if the function is too long. Instead I’d make that function return the item, and you can collect the results locally.

    def create_report(fix, description): # I've changed the name to snake_casing
        fix.description = description
        return fix
    
    def unit_history(request,unitid, syear, smonth, sday, shour, fyear, fmonth, fday, fhour, type=None):
        reports = []
        waypoints = Fixes.objects.filter(name=(unitid))
        waypoints = waypoints.filter(gpstime__range=(awareStartTime, awareEndTime)).order_by('gpstime')[:1000]
        if waypoints:
            for index in range(len(waypoints)): 
                report = create_report(waypointsindex, description)
                reports.append(report)
        return render_to_response('unitHistory.html', {'fixes': reportResults})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a website using master page, which works fine. but after I
I need some help creating this extension method. My view inherits from <%@ Page
I'm creating a list with itertools from a list of ranges, so far I
I'm creating a class that derives from List... public class MyList : List<MyListItem> {}
I am creating a CSV from a list of values. CSV File gets created
Why does this attempt at creating a list of curried functions not work? def
I have a list of linear and non-linear models derived from different data sets
Background I have a payment page where the user can select from a list
I am creating a sortable list of items from my database using the railscast
I'm having some trouble creating custom routes for my blog module (which I'm doing

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.