MCPcopy
hub / github.com/django/django / save

Method save

django/contrib/sessions/backends/db.py:114–137  ·  view source on GitHub ↗

Save the current session data to the database. If 'must_create' is True, raise a database error if the saving operation doesn't create a new entry (as opposed to possibly updating an existing entry).

(self, must_create=False)

Source from the content-addressed store, hash-verified

112 )
113
114 def save(self, must_create=False):
115 """
116 Save the current session data to the database. If 'must_create' is
117 True, raise a database error if the saving operation doesn't create a
118 new entry (as opposed to possibly updating an existing entry).
119 """
120 if self.session_key is None:
121 return self.create()
122 data = self._get_session(no_load=must_create)
123 obj = self.create_model_instance(data)
124 using = router.db_for_write(self.model, instance=obj)
125 try:
126 with transaction.atomic(using=using):
127 obj.save(
128 force_insert=must_create, force_update=not must_create, using=using
129 )
130 except IntegrityError:
131 if must_create:
132 raise CreateError
133 raise
134 except DatabaseError:
135 if not must_create:
136 raise UpdateError
137 raise
138
139 async def asave(self, must_create=False):
140 """See save()."""

Callers 4

createMethod · 0.95
sessionMethod · 0.95
process_responseMethod · 0.45
sync_transactionMethod · 0.45

Calls 4

createMethod · 0.95
create_model_instanceMethod · 0.95
_get_sessionMethod · 0.80
db_for_writeMethod · 0.45

Tested by

no test coverage detected