Changes between Version 10 and Version 11 of NewAdminChanges


Ignore:
Timestamp:
10/18/2005 03:40:51 PM (10 years ago)
Author:
rjwittams
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NewAdminChanges

    v10 v11  
    8484This is the set of fields shown by the admin.
    8585
    86 (insert example)
     86{{{
     87def style_edit_inline(request, object_id):   
     88    try:
     89        follow = {
     90           'choices' : True,
     91        }
     92        manipulator = styles.ChangeManipulator(object_id, follow) <------ EXTRA ARGUMENT
     93    except ObjectDoesNotExist:
     94        raise Http404
     95
     96    if request.POST:
     97        new_data = request.POST.copy()
     98       
     99        errors = manipulator.get_validation_errors(new_data)
     100       
     101        manipulator.do_html2python(new_data)
     102        if not errors:
     103            manipulator.save(new_data)
     104            return HttpResponseRedirect("")
     105    else:
     106        # Populate new_data with a "flattened" version of the current data.
     107        new_data = manipulator.flatten_data()
     108        errors = {}
     109       
     110
     111    # Populate the FormWrapper.
     112    form = formfields.FormWrapper(manipulator, new_data, errors, edit_inline = True) # ,----- EXTRA ARGUMENT
     113   
     114 
     115    return render_to_response('style_edit_inline', { 'form': form })
     116
     117}}}
    87118
    88119Manipulators have a new method, {{{flatten_data()}}}. This takes the data from the existing object (or the defaults in the case of an {{{AddManipulator}}}) and turns it into a suitable form for an HTTP post. It must be called before creating the formfield wrapper is created.
    89 
    90 The data from a post must have {{{manipulator.do_html2python(new_data)}}} called on it before it is used to repopulate a formfieldwrapper.
    91 
    92120
    93121== Templates ==
Back to Top