Changes between Version 149 and Version 150 of RemovingTheMagic
- Timestamp:
- May 23, 2006, 4:12:24 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RemovingTheMagic
v149 v150 9 9 Additional 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. 10 10 11 [[ TOC(inline, RemovingTheMagic)]]11 [[PageOutline]] 12 12 13 13 == How to get the branch == … … 460 460 }}} 461 461 462 === `__repr__()` model method isreplaced by `__str__()` ===462 === `__repr__()` replaced by `__str__()` === 463 463 464 464 You should use `__str__()` where `__repr__()` was formerly used, i.e., as a string representation of the model. … … 519 519 Also, 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. 520 520 521 === Model methods no longer automatically have access to datetime and db modules===521 === `datetime` and `db` modules must be imported explicitly === 522 522 523 523 Formerly, 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. … … 715 715 (see "You can override default QuerySets" for more on QuerySets) 716 716 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 === 718 718 719 719 Proper 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: … … 778 778 * New: {{{django.contrib.admin.urls}}} 779 779 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 782 Formerly, these helper methods took a model module as their first positional argument. Now, they expect a model class. 781 783 782 784 Old: