mirror of
https://github.com/django/django.git
synced 2024-12-28 03:55:50 +00:00
6b4834952d
Model.save() will use UPDATE - if not updated - INSERT instead of SELECT - if found UPDATE else INSERT. This should save a query when updating, but will cost a little when inserting model with PK set. Also fixed #17341 -- made sure .save() commits transactions only after the whole model has been saved. This wasn't the case in model inheritance situations. The save_base implementation was refactored into multiple methods. A typical chain for inherited save is: save_base() _save_parents(self) for each parent: _save_parents(parent) _save_table(parent) _save_table(self)
16 lines
282 B
Python
16 lines
282 B
Python
from django.db import models
|
|
|
|
|
|
class Mod(models.Model):
|
|
fld = models.IntegerField()
|
|
|
|
class SubMod(Mod):
|
|
cnt = models.IntegerField(unique=True)
|
|
|
|
class M2mA(models.Model):
|
|
others = models.ManyToManyField('M2mB')
|
|
|
|
|
|
class M2mB(models.Model):
|
|
fld = models.IntegerField()
|