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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:38:06+00:00 2026-05-22T00:38:06+00:00

I have a view which queries a model to populate a form: class AddServerForm(forms.Form):

  • 0

I have a view which queries a model to populate a form:

class AddServerForm(forms.Form):
    …snip…
    # Compile and present choices for HARDWARE CONFIG
    hwChoices = HardwareConfig.objects.\
        values_list('name','description').order_by('name')
    hwChoices = [('', '----- SELECT ONE -----')] +\
        [ (x,'{0} - {1}'.format(x,y)) for x,y in hwChoices ]

    hwconfig = forms.ChoiceField(label='Hardware Config', choices=hwChoices)
    …snip…

def addServers(request, template="manager/add_servers.html",
    template_success="manager/add_servers_success.html"):
    if request.method == 'POST':
        # …snip… - process the form
    else:
        # Page was called via GET - use a default form
        addForm = AddServerForm()

    return render_to_response(template, dict(addForm=addForm),
        context_instance=RequestContext(request))

Additions to the HardwareConfig model are done using the admin interface. Changes show up immediately in the admin interface as expected.

Running the query via the shell returns all results as expected:

michael@victory> python manage.py shell
Python 2.6 (r26:66714, Feb 21 2009, 02:16:04)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from serverbuild.base.models import HardwareConfig
>>> hwChoices = HardwareConfig.objects.\
...         values_list('name','description').order_by('name')

hwChoices now contains the complete set of results.

However, loading the addServers view (above) returns the old result set, missing the newly-added entries.

I have to restart the webserver in order for the changes to show up which makes it seem as though that query is being cached somewhere.

  • I’m not doing any explicit caching anywhere (grep -ri cache /project/root returns nothing)
  • It’s not the browser caching the page – inspected via chrome tools, also tried using a different user & computer

What’s going wrong and how do I fix it?


Versions:

  • MySQLdb: 1.2.2
  • django: 1.2.5
  • python: 2.6
  • 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-05-22T00:38:06+00:00Added an answer on May 22, 2026 at 12:38 am

    hwChoices is evaluated when the form is defined – ie when the process starts.

    Do the calculation in the form’s __init__ method instead.

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

Sidebar

Related Questions

I have a view which contains a form, the form posts and the data
I have a View class (OrderView.aspx) which shows the details of an order (Account
I currently have a list view which has several rows of data and I
I have a list view control which at the moment only allows one item
I have an ASP.NET MVC view which contains checkboxes for user-defined categories. <td><% foreach
I have an application, built using MVC, that produces a view which delivers summary
I have a strongly-typed MVC View Control which is responsible for the UI where
I have a feature which allows the user to create projects and view it
I have quite a lot of PHP view files, which I used to include
Here's the problem I'm having in my ASP.NET web-form project. I have Datalist which

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.