Changes between Version 30 and Version 31 of NewAdminChanges
- Timestamp:
- Aug 9, 2006, 3:54:48 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NewAdminChanges
v30 v31 6 6 Templates are generated at run time in a way which makes them hard to understand and reuse. 7 7 The 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. 9 9 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. 10 10 … … 24 24 25 25 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. 27 27 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. 28 28 … … 44 44 manipulator.do_html2python(new_data) # WRONG!! 45 45 manipulator.save(new_data) 46 return HttpResponseRedirect( "")46 return HttpResponseRedirect('') 47 47 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. 49 49 new_data = manipulator.original_object.__dict__ # WRONG!! 50 50 errors = {} … … 74 74 if not errors: 75 75 manipulator.save(new_data) 76 return HttpResponseRedirect( "")76 return HttpResponseRedirect('') 77 77 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. 79 79 new_data = manipulator.flatten_data() # CORRECT!! 80 80 errors = {} … … 102 102 This is the set of fields shown by the admin. 103 103 104 Currently, the FormWrapper must be passed edit_inline=True to gain access to these fields.104 Currently, the !FormWrapper must be passed edit_inline=True to gain access to these fields. 105 105 This will probably be removed. 106 106 … … 161 161 'choices' : True, 162 162 } 163 manipulator = styles.ChangeManipulator(object_id, follow)# <------ EXTRA ARGUMENT163 manipulator = styles.ChangeManipulator(object_id, follow)# <------ EXTRA ARGUMENT 164 164 except ObjectDoesNotExist: 165 165 raise Http404 … … 173 173 if not errors: 174 174 manipulator.save(new_data) 175 return HttpResponseRedirect( "")175 return HttpResponseRedirect('') 176 176 else: 177 # Populate new_data with a "flattened"version of the current data.177 # Populate new_data with a 'flattened' version of the current data. 178 178 new_data = manipulator.flatten_data() 179 179 errors = {} … … 181 181 182 182 # Populate the FormWrapper. 183 form = formfields.FormWrapper(manipulator, new_data, errors, edit_inline = True) # <----- EXTRA ARGUMENT183 form = formfields.FormWrapper(manipulator, new_data, errors, edit_inline = True) # <----- EXTRA ARGUMENT 184 184 185 185 … … 217 217 ... 218 218 def monkey_tag(verb): 219 return "I %s no evil"% verb219 return 'I %s no evil' % verb 220 220 monkey_tag = simple_tag(monkey_tag) 221 221 … … 225 225 {{{ 226 226 {% load monkey %} 227 {% monkey_tag "hear"%}227 {% monkey_tag 'hear' %} 228 228 }}} 229 229 … … 236 236 An 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 : 237 237 238 * admin/ <app_label>/<object_name>/change_form239 * admin/ <app_label>/change_form238 * admin/<app_label>/<object_name>/change_form 239 * admin/<app_label>/change_form 240 240 * admin/change_form 241 241 … … 248 248 {{{ 249 249 250 {%extends "admin/change_form"%}250 {%extends 'admin/change_form' %} 251 251 252 252 {% block branding %} Customised title {% endblock %} … … 255 255 }}} 256 256 257 This 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").257 This 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' ). 258 258 259 259 In the change forms, the following blocks are available for custom overriding: 260 260 261 * branding - included from "admin/base"261 * branding - included from 'admin/base'; 262 262 * form_top - at the top of the form after the title. 263 263 * after_field_sets - after standard field sets, before the related objects … … 265 265 266 266 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. 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. 268