Changes between Initial Version and Version 1 of Ticket #16173
- Timestamp:
- Jun 8, 2011, 3:23:36 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #16173
- Property UI/UX unset
-
Ticket #16173 – Description
initial v1 1 __get__ onForeignKey field uses manager to query the values.1 `__get__` on !ForeignKey field uses manager to query the values. 2 2 3 The code is as given below 3 The code is as given below: 4 4 5 # If the related manager indicates that it should be used for 5 {{{ 6 # If the related manager indicates that it should be used for 6 7 # related fields, respect that. 7 8 rel_mgr = self.field.rel.to._default_manager … … 9 10 if getattr(rel_mgr, 'use_for_related_fields', False): 10 11 rel_obj = rel_mgr.using(db).get(**params) 11 12 Check the last line 'rel_obj = rel_mgr.using(db).get(**params)' for using rel_mgr with multiple databases. rel_mgr.using(db) returns a queryset. If developer has written a Custom Manager class for which 'get' is overriden, then Custom Managers 'get' function will never get called. This results in surprises to the developer. I think this line should changed to 12 }}} 13 14 Check the last line `rel_obj = rel_mgr.using(db).get(**params)` for using `rel_mgr` with multiple databases. `rel_mgr.using(db)` returns a queryset. If developer has written a custom manager class for which `get` is overriden, then custom managers `get` function will never get called. This results in surprises to the developer. I think this line should changed to: 13 15 16 {{{ 14 17 rel_obj = rel_mgr.db_manager(db).get(**params) 15 16 18 }}}