#14969: To have a way to modify third part model classes
---------------------------------------------------+------------------------
          Reporter:  marinho                       |         Owner:  nobody
            Status:  closed                        |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  SVN   
        Resolution:  wontfix                       |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by schinckel):

 If you really feel the need to MonkeyPatch (and sometimes, it is
 unavoidable), then just use `Model.add_to_class`.

 You can even do this to modify contrib apps' models (for instance, I use
 it to add a field to `Group`, so I can have a hierarchy of groups).

 Just make sure you are very careful with your patching (ie, check to see
 if the field/attribute/method already exists on the model class, for
 instance). And be aware that you may break things.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14969#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to