Created
          July 26, 2010 19:41 
        
      - 
      
- 
        Save vbmendes/491111 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class MyModelAdmin(ModelAdmin): | |
| ... | |
| def __getattr__(self, name): | |
| """ | |
| Permite o uso de um atributo no admin com o nome | |
| do atributo mais '_or_blank'. Exemplo: name_or_blank | |
| """ | |
| if name.endswith('_or_blank'): | |
| try: | |
| return getattr(self, name[:-9]) or u'' | |
| except AttributeError: | |
| pass | |
| return super(MyModelAdmin, self).__getattr__(name) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment