﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
298	Need impovement to POST.copy()	mr_little	Adrian Holovaty	"When i need to change only few fields of model, for example only date_start field of Project, i need to pass a values of other fields like new_data variable into manipulator.* methods ('coz they are not present in POST)

The only place of values of other fields is Project.__dict__

But manipulator.* methods expects new_data.values() like strings. And Project.__dict__ contains .values() like python-values.

Also, new_data must be MultiValueDict

So, i need to make new_data like this (it's a simple shortened example without checks):

{{{
def start(req, p_id):
    """"""
    Updates ""start"" information about project
    Such as start_date, start_people e.t.c.
    """"""
    try:
        prj = projects.get_object(pk=rp_id)
    except projects.ProjectDoesNotExist:
        raise Http404

    manipulator = projects.ChangeManipulator(prj.id)
    new_data = prj.__dict__ # all fields of Project
            
    errors = dict()
            
    if req.POST:
        #only tree fields changed, and values of them are in req.POST
        new_data = update_post(req.POST.copy(), new_data)
        errors = manipulator.get_validation_errors(new_data)
        
        mnp.do_html2python(new_data)
        mnp.save(new_data)
}}}

Where the update_post() is like this:

{{{
def update_post(post, data):
    for key in data:
        if not key in post.keys():
            if data[key]:
                post[key]=str(data[key])
            else:
                post[key]=''
    return post
}}}

But it's easy to say:
{{{
    new_data = req.POST.copy(new_data) # default values like param
#or
    new_data.update(req.POST)

}}}

or something like this...

"	enhancement	closed	Core (Other)		normal	wontfix			Unreviewed	0	0	0	0	0	0
