Changes between Version 2 and Version 6 of Ticket #32563


Ignore:
Timestamp:
Mar 18, 2021, 3:14:50 AM (3 years ago)
Author:
Lucas Gruber
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32563 – Description

    v2 v6  
    7070I noticed that all the methods of ''RelatedManager'' directly call the router object to find the database while the ''Manager'' objects always exploits the possibility of overriding the database with the call to ''using()'' on the QuerySet or to pass parameter ''using=db'' for save model method for example.
    7171
     72I guess we need to use a mecanism which we can find in Model class with the save method :
     73{{{
     74    def save(self, force_insert=False, force_update=False, using=None,
     75             update_fields=None):
     76        [...]
     77        using = using or router.db_for_write(self.__class__, instance=self)
     78        [...]
     79}}}
     80
     81Thus, we will be able to override the database at the time of the save.
    7282
    7383Thank you in advance for your answer
Back to Top