Changes between Initial Version and Version 1 of Ticket #28344, comment 31
- Timestamp:
- Dec 11, 2023, 10:17:19 AM (12 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28344, comment 31
initial v1 14 14 {{{#!python 15 15 queryset = Author.objects.all() # As opposed to `_base_manager` the default manager could be doing `filter(deleted_at=None)` 16 author.refresh_from_db(from_queryset=queryset) 16 author.refresh_from_db(from_queryset=queryset) # Which would respect raising `DoesNotExist` 17 17 }}} 18 19 That would make implementing a model mixin that supports a `select_for_update` override quite easy 20 21 {{{#!python 22 class BaseModel(models.Model): 23 class Meta: 24 abstract = True 25 26 def refresh_from_db(self, using=None, fields=None, from_queryset=None, select_for_update=False): 27 if select_for_update: 28 from_queryset = ( 29 self.__class__._base_manager.db_manager(using) 30 if from_queryset is None 31 else from_queryset 32 ).select_for_update() 33 return super().refresh_from_db(fields=fields, from_queryset=from_queryset) 34 }}}