| 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 | {{{ |
| 49 | from 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 | |