Changes between Version 29 and Version 30 of RemovingTheMagic


Ignore:
Timestamp:
01/06/06 16:26:11 (9 years ago)
Author:
adrian
Comment:

Added section about how managers access their associated class

Legend:

Unmodified
Added
Removed
Modified
  • RemovingTheMagic

    v29 v30  
    135135}}}
    136136
    137 == Multiple managers ==
     137== Custom managers, and multiple managers ==
    138138
    139139'''Status: Done'''
     
    207207}}}
    208208
     209If a manager needs to access its associated class, it should use {{{self.klass}}}. Example:
     210
     211{{{
     212#!python
     213class PersonManager(models.Manager):
     214    def get_fun_person(self):
     215        try:
     216            return self.get_object(fun__exact=True)
     217        except self.klass.DoesNotExist:
     218            print "Doesn't exist."
     219}}}
     220
    209221== Renamed !DoesNotExist exception ==
    210222
Back to Top