Changes between Version 2 and Version 3 of MagicRemovalCheatSheet


Ignore:
Timestamp:
05/11/2006 10:34:19 PM (9 years ago)
Author:
eugene@…
Comment:

added views

Legend:

Unmodified
Added
Removed
Modified
  • MagicRemovalCheatSheet

    v2 v3  
    4141 1. [wiki:RemovingTheMagic#a__repr__modelmethodisreplacedby__str__ Replace __repr__ with __str__].
    4242 1. If you use {{{_pre_save()}}}, {{{_post_save()}}}, {{{_pre_delete()}}}, and/or {{{_post_delete()}}} hooks, [wiki:RemovingTheMagic#Addedamorepowerfulwayofoverridingmodelmethodsremovedhardcoded_pre_save_post_saveetc. replace them] by overriding {{{save()}}} and {{{delete()}}} methods.
     43 1. If your model has {{{objects}}} attribute, [wiki:RemovingTheMagic#Overridedefaultmanagernameobjects rename it].
    4344
    4445== Views ==
     46
     47 1. [wiki:RemovingTheMagic#Interactdirectlywithmodelclassesnotwithmagicmodules Import your models directly] the Python way. For example, if your model {{{Person}}} is in {{{yourproject/yourapp/models.py}}} file, use:
     48{{{
     49from yourproject.yourapp.models import Person
     50}}}
     51 1. [wiki:RemovingTheMagic#Namespacesimplification Change import statements] to reflect the namespace simplification:
     52   * {{{django.utils.httpwrappers}}} => {{{django.http}}}
     53   * {{{django.core.exceptions.Http404}}} => {{{django.http.Http404}}}
     54   * {{{django.core.template}}} => {{{django.template}}}
     55   * {{{django.core.formfields}}} => {{{django.forms}}}
     56   * {{{django.core.extensions}}} => {{{django.shortcuts}}}
     57   * '''renamed:''' {{{django.core.extensions.DjangoContext}}} => {{{django.template.RequestContext}}}
     58 1. Former module {{{settings}}} is an instance now. [wiki:RemovingTheMagic#Movedsettingsintoaninstance Import it] using {{{from django.cong import settings}}}.
     59 1. [wiki:RemovingTheMagic#Includetemplateextensionexplicitly Include template extensions explicitly].
     60 1. [wiki:RemovingTheMagic#Descriptorfields Convert to new Database API]. ''Warning: usually this is the most time-consuming step. Be careful!''
     61 1. [wiki:RemovingTheMagic#RenamedDoesNotExistexception Rename DoesNotExist exception]: {{{people.PersonDoesNotExist}}} becomes {{{Person.DoesNotExist}}}.
     62 1. If you use {{{get_object_or_404()}}} and {{{get_list_or_404()}}}, [wiki:RemovingTheMagic#get_object_or_404andget_list_or_404nowtakemodelclassesnotmodules change their parameters]. Note: you cannot use ''field''{{{__ne}}} and {{{order_by}}} keywords. Use {{{exclude()}}} and {{{order_by()}}} methods of [wiki:RemovingTheMagic#Descriptorfields new Database API].
     63 1. If you use Django's authentication, [wiki:RemovingTheMagic#Authenticationhasbeenconsolidated update your code to reflect the consolidation].
     64 1. If you use manipulators, [wiki:RemovingTheMagic#Changedinterfacetomanipulators update your code]: {{{django.core.formfields}}} is {{{django.forms}}} now.
     65
    4566== Templates ==
    4667== Template tags ==
    47 == Settings ==
     68== Settings and URLs ==
    4869
    4970== Post-conversion ==
Back to Top