Changes between Version 30 and Version 31 of NewAdminChanges


Ignore:
Timestamp:
Aug 9, 2006, 3:54:48 AM (18 years ago)
Author:
bryan
Comment:

Fixed html entities etc.

Legend:

Unmodified
Added
Removed
Modified
  • NewAdminChanges

    v30 v31  
    66Templates are generated at run time in a way which makes them hard to understand and reuse.
    77The aims of the new-admin branch are
    8  1. Remove the need for these workarounds, so that writing straight forward code can achieve the results that would be expected from the admin behaviour. This entails a fair number of changes to FormFields, Fields, and the meta system.
     8 1. Remove the need for these workarounds, so that writing straight forward code can achieve the results that would be expected from the admin behaviour. This entails a fair number of changes to !FormFields, Fields, and the meta system.
    99 2. Replace the runtime template generation system with a set of templates and template tags that acheive very nearly the same output as the current admin modulo whitespace. During this work, it became tedious to debug certain classes of template errors, and so debugging facilities were added to the template system.
    1010
     
    2424
    2525 1. Make sure html2python is called regardless of whether there are errors, but '''after''' validation.
    26  2. Make sure you use flatten_data to get your new_data to fill in your forms, NOT just the {{{__dict__}}} of the object you are editing, or an empty dict with an AddManipulator. Otherwise, dates, foreign keys, inline editing and a  whole host of other things will NOT work properly, just like they do not work on trunk.
     26 2. Make sure you use flatten_data to get your new_data to fill in your forms, NOT just the {{{__dict__}}} of the object you are editing, or an empty dict with an !AddManipulator. Otherwise, dates, foreign keys, inline editing and a  whole host of other things will NOT work properly, just like they do not work on trunk.
    2727 3. Make sure you remove any hacks for modifying the data in your view function. This is now done by the fields themselves in flatten_data and instances where it works unexpectedly should be filed as bugs.
    2828
     
    4444            manipulator.do_html2python(new_data)   # WRONG!!
    4545            manipulator.save(new_data)
    46             return HttpResponseRedirect("")
     46            return HttpResponseRedirect('')
    4747    else:
    48         # Populate new_data with a "flattened" version of the current data.
     48        # Populate new_data with a 'flattened' version of the current data.
    4949        new_data = manipulator.original_object.__dict__ # WRONG!!
    5050        errors = {}
     
    7474        if not errors:
    7575            manipulator.save(new_data)
    76             return HttpResponseRedirect("")
     76            return HttpResponseRedirect('')
    7777    else:
    78         # Populate new_data with a "flattened" version of the current data.
     78        # Populate new_data with a 'flattened' version of the current data.
    7979        new_data = manipulator.flatten_data() # CORRECT!!
    8080        errors = {}
     
    102102This is the set of fields shown by the admin.
    103103
    104 Currently, the FormWrapper must be passed edit_inline=True to gain access to these fields.
     104Currently, the !FormWrapper must be passed edit_inline=True to gain access to these fields.
    105105This will probably be removed.
    106106
     
    161161           'choices' : True,
    162162        }
    163         manipulator = styles.ChangeManipulator(object_id, follow)# <------ EXTRA ARGUMENT
     163        manipulator = styles.ChangeManipulator(object_id, follow)# <------ EXTRA ARGUMENT
    164164    except ObjectDoesNotExist:
    165165        raise Http404
     
    173173        if not errors:
    174174            manipulator.save(new_data)
    175             return HttpResponseRedirect(&#34;&#34;)
     175            return HttpResponseRedirect('')
    176176    else:
    177         # Populate new_data with a &#34;flattened&#34; version of the current data.
     177        # Populate new_data with a 'flattened' version of the current data.
    178178        new_data = manipulator.flatten_data()
    179179        errors = {}
     
    181181
    182182    # Populate the FormWrapper.
    183     form = formfields.FormWrapper(manipulator, new_data, errors, edit_inline = True) # &lt;----- EXTRA ARGUMENT
     183    form = formfields.FormWrapper(manipulator, new_data, errors, edit_inline = True) # <----- EXTRA ARGUMENT
    184184   
    185185 
     
    217217...
    218218def monkey_tag(verb):
    219     return &#34;I %s no evil&#34; % verb
     219    return 'I %s no evil' % verb
    220220monkey_tag = simple_tag(monkey_tag)
    221221
     
    225225{{{
    226226{% load monkey %}
    227 {% monkey_tag &#34;hear&#34; %}
     227{% monkey_tag 'hear' %}
    228228}}}
    229229
     
    236236An example is change forms - these are the forms used to modify and add objects in the admin. The templates are selected in the following order :
    237237
    238  * admin/&lt;app_label&gt;/&lt;object_name&gt;/change_form
    239  * admin/&lt;app_label&gt;/change_form
     238 * admin/<app_label>/<object_name>/change_form
     239 * admin/<app_label>/change_form
    240240 * admin/change_form
    241241
     
    248248{{{
    249249
    250 {%extends &#34;admin/change_form&#34; %}
     250{%extends 'admin/change_form' %}
    251251
    252252{% block branding %} Customised title {% endblock %}
     
    255255}}}
    256256
    257 This works using normal template inheritance, so make sure you inherit from the right thing ( usually &#34;admin/change_form&#34;, but for an object in an app that has its own change form, it may be &#34;admin/&lt;app_name&gt;/change_form&#34; ). 
     257This works using normal template inheritance, so make sure you inherit from the right thing ( usually 'admin/change_form', but for an object in an app that has its own change form, it may be 'admin/<app_name>/change_form' ). 
    258258
    259259In  the change forms, the following blocks are available for custom overriding:
    260260
    261  * branding - included from &#34;admin/base&#34;
     261 * branding - included from 'admin/base';
    262262 * form_top - at the top of the form after the title.
    263263 * after_field_sets - after standard field sets, before the related objects
     
    265265
    266266
    267 Inline editing can be customised. rather than using edit_inline=meta.TABULAR or meta.SOURCE, you can define a custom inline editing mode. This is done by subclassing BoundRelatedObject, and using that class. eg edit_inline=HorizontalScroller.
     267Inline editing can be customised. rather than using edit_inline=meta.TABULAR or meta.SOURCE, you can define a custom inline editing mode. This is done by subclassing !BoundRelatedObject, and using that class. eg edit_inline=!HorizontalScroller.
     268
Back to Top