python - Cannot Edit in Django -


i have following views:

def unit_edit(request,pk):     post = unit.objects.get(pk=pk)     if request.method == "post":         vehicle_group   = request.post.get('vehicle_group'),         unit_name       = request.post.get('unit_name'),         start_hm        = request.post.get('start_hm'),         operation_date  = request.post.get('operation_date'),         coremoduleid    = request.post.get('coremoduleid'),         mqmoduleid      = request.post.get('mqmoduleid'),         radiomoduleid   = request.post.get('radiomoduleid'),         post.save()      t = loader.get_template('unit_edit.html')     c = requestcontext(request, {'unit': post})      return httpresponse(t.render(c)) 

the problem:

when try edit given object (data), cannot data edited.

you not editing object database. code setting number of variables not object attributes. need prefix variables post object.

by doing post.variable_name = <value> modifying objects attribute value.

by doing variable_name = <value> creating , setting value function variable.

def unit_edit(request,pk):     post = unit.objects.get(pk=pk)     if request.method == "post":         post.vehicle_group   = request.post.get('vehicle_group'),         post.unit_name       = request.post.get('unit_name'),         post.start_hm        = request.post.get('start_hm'),         post.operation_date  = request.post.get('operation_date'),         post.coremoduleid    = request.post.get('coremoduleid'),         post.mqmoduleid      = request.post.get('mqmoduleid'),         post.radiomoduleid   = request.post.get('radiomoduleid'),         post.save() 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -