Changes between Version 149 and Version 150 of RemovingTheMagic


Ignore:
Timestamp:
05/23/2006 04:12:24 AM (9 years ago)
Author:
pb@…
Comment:

attempted cleanup of TOC

Legend:

Unmodified
Added
Removed
Modified
  • RemovingTheMagic

    v149 v150  
    99Additional resource: the [wiki:MagicRemovalCheatSheet "magic-removal" cheat sheet], which can be used as a reference for conversion to the "magic-removal" branch. It contains links to this document organized by functional areas.
    1010
    11 [[TOC(inline, RemovingTheMagic)]]
     11[[PageOutline]]
    1212
    1313== How to get the branch ==
     
    460460}}}
    461461
    462 === `__repr__()` model method is replaced by `__str__()` ===
     462=== `__repr__()` replaced by `__str__()` ===
    463463
    464464You should use `__str__()` where `__repr__()` was formerly used, i.e., as a string representation of the model.
     
    519519Also, the various backend functionality has been split into three separate modules for each backend -- {{{base.py}}}, {{{creation.py}}} and {{{introspection.py}}}. This is purely for performance and memory savings, so that basic, everyday Django usage doesn't have to load the introspective functionality into memory.
    520520
    521 === Model methods no longer automatically have access to datetime and db modules ===
     521=== `datetime` and `db` modules must be imported explicitly ===
    522522
    523523Formerly, each model method magically had access to the {{{datetime}}} module and to the variable {{{db}}}, which represents the current database connection. Now, those have to be imported explicitly.
     
    715715(see "You can override default QuerySets" for more on QuerySets)
    716716
    717 === Added a more powerful way of overriding model methods, removed hard-coded _pre_save(), _post_save(), etc. ===
     717=== Overriding save() and delete() model methods ===
    718718
    719719Proper subclassing of methods now works, so you can subclass the automatic {{{save()}}} and {{{delete()}}} methods. This removes the need for the {{{_pre_save()}}}, {{{_post_save()}}}, {{{_pre_delete()}}} and {{{_post_delete()}}} hooks -- all of which have been removed. Example:
     
    778778 * New: {{{django.contrib.admin.urls}}}
    779779
    780 === get_object_or_404 and get_list_or_404 now take model classes, not modules ===
     780=== get_object_or_404 and get_list_or_404 take model classes ===
     781
     782Formerly, these helper methods took a model module as their first positional argument. Now, they expect a model class.
    781783
    782784Old:
Back to Top