mysql - Django query executed in view returns old data -
i have view queries model populate form:
class addserverform(forms.form): …snip… # compile , present choices hardware config hwchoices = hardwareconfig.objects.\ values_list('name','description').order_by('name') hwchoices = [('', '----- select 1 -----')] +\ [ (x,'{0} - {1}'.format(x,y)) 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 form else: # page called via - use default form addform = addserverform() return render_to_response(template, dict(addform=addform), context_instance=requestcontext(request))
additions hardwareconfig model done using admin interface. changes show in admin interface expected.
running query via shell returns results 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" more information. (interactiveconsole) >>> serverbuild.base.models import hardwareconfig >>> hwchoices = hardwareconfig.objects.\ ... values_list('name','description').order_by('name')
hwchoices contains complete set of results.
however, loading addservers view (above) returns old result set, missing newly-added entries.
i have restart webserver in order changes show makes seem though query being cached somewhere.
- i'm not doing explicit caching anywhere (
grep -ri cache /project/root
returns nothing) - it's not browser caching page - inspected via chrome tools, tried using different user & computer
what's going wrong , how fix it?
versions:
- mysqldb: 1.2.2
- django: 1.2.5
- python: 2.6
hwchoices
evaluated when form defined - ie when process starts.
do calculation in form's __init__
method instead.
Comments
Post a Comment