I get an SQL error when trying to Change an already displayed form
field.

When loggedin() returns True and changes have already been made at are
currently trying to be submitted, this view is still tries to INSERT:

def changeaccount(request):
   uid = '-1'
   if loggedin(request.user):
      uid = request.user.id
      thisuser = accounts.get_object(uid__exact=uid)
      manipulator = accounts.ChangeManipulator(thisuser.id)
      thisaccount = manipulator.original_object
   else:
      manipulator = accounts.AddManipulator()

   if request.POST:
      new_data = request.POST.copy()
      errors = manipulator.get_validation_errors(new_data)
      if not errors:
         manipulator.do_html2python(new_data)
         manipulator.save(new_data)
         return HttpResponseRedirect('/thanks')
   else:
      errors = new_data = {}
      if loggedin(request.user):
         new_data = thisaccount.__dict__
   form = formfields.FormWrapper(manipulator, new_data, errors)
   return render_to_response('nwmail/account', {'form': form,
      'uid':uid,
      'loggedin':loggedin(request.user),
      'searchbar':searchbar(request),
      'crumbsbar':crumbsbar(request),
   })


The manipulator is a AccountManipulatorChange. I double checked by
calling HttpResponse on manipulator.__class__.__name__.

I do use a "_pre_save" in my model and I was wondering if this somehow
was causing this unexpected behaviour.

tia,

Brian Ray
<http://brianray.chipy.org> aim: brianray34

Reply via email to