Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2846 closed defect (worksforme)

something wrong in manipulators

Reported by: fiorix@… Owned by: Adrian Holovaty
Component: Core (Other) Version: 0.95
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have a Person model like this:

class Person(models.Model):
  user = OneToOneField(User)
  dept = ForeignKey(Department)
  phone = ...

Also I have a form for any user change its own account settings. The code is:

def index(request):
    manip = Person.ChangeManipulator(request.user)
    if request.POST:
        new_data = request.POST.copy()
        errors = manip.get_validation_errors(new_data)

        if not errors:
            return HttpResponseRedirect('/tosco/')

        errors = {}
        new_data = manip.flatten_data()

    form = forms.FormWrapper(manip, new_data, errors)
    return render_to_response('tosco.html', {'form':form})

When I submit the POST to the form I get an error like this:

ProgrammingError at /tosco/
ERROR: column "alec" does not exist SELECT 1 FROM "person_person" WHERE "user_id"=alec LIMIT 1

OK. I discovered that the data in new_data is fine, with the id number of the user 'alec'. But when I call it's being changed to the value 'alec' instead of the id number, at /path-to/django/db/models/ line 97:

if self.change:
   params[] = self.obj_key

I don't know why this is happening but if I change that to it works fine. Is that a bug?

Change History (1)

comment:1 Changed 14 years ago by James Bennett

Resolution: worksforme
Status: newclosed

ChangeManipulator excepts an object id to be passed to it, not an object; doing

manip = Person.ChangeManipulator(

should be fine.

Note: See TracTickets for help on using tickets.
Back to Top