Code

Changes between Version 28 and Version 29 of RemovingTheMagic


Ignore:
Timestamp:
01/06/06 14:21:58 (8 years ago)
Author:
adrian
Comment:

Added 'Model methods no longer automatically have access to datetime and db modules'

Legend:

Unmodified
Added
Removed
Modified
  • RemovingTheMagic

    v28 v29  
    283283}}} 
    284284 
     285== Model methods no longer automatically have access to datetime and db modules == 
     286 
     287'''Status: Done''' 
     288 
     289Formerly, 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. 
     290 
     291Old: 
     292{{{ 
     293#!python 
     294    def some_method(self): 
     295        print datetime.datetime.now() 
     296        cursor = db.cursor() 
     297        cursor.execute("UPDATE something;") 
     298}}} 
     299 
     300New: 
     301{{{ 
     302#!python 
     303import datetime 
     304from django.db import connection 
     305 
     306# ... 
     307 
     308    def some_method(self): 
     309        print datetime.datetime.now() 
     310        cursor = connection.cursor() 
     311        cursor.execute("UPDATE something;") 
     312}}} 
     313 
    285314== Move "auth" and "core" models to django.contrib == 
    286315