Fixed #19501 -- added Model.from_db() method

Implements a new from_db() method for models. The method can be used to customize or speed up model loading.
I think assert here is fine - this shouldn't ever happen, and the assert is there just to catch bugs. So, in -0 mode skipping this check is OK. There are other similar uses, also.