| | 285 | == Model methods no longer automatically have access to datetime and db modules == |
| | 286 | |
| | 287 | '''Status: Done''' |
| | 288 | |
| | 289 | 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. |
| | 290 | |
| | 291 | Old: |
| | 292 | {{{ |
| | 293 | #!python |
| | 294 | def some_method(self): |
| | 295 | print datetime.datetime.now() |
| | 296 | cursor = db.cursor() |
| | 297 | cursor.execute("UPDATE something;") |
| | 298 | }}} |
| | 299 | |
| | 300 | New: |
| | 301 | {{{ |
| | 302 | #!python |
| | 303 | import datetime |
| | 304 | from 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 | |