The save () documentation explains that:
A subclass of ModelForm can accept an existing instance of the model as a keyword argument; if it is set, save () will update this example. If it is not specified, save () will create a new instance of the specified model
However, self.instancein save()always has an object.
self.instance
save()
So, how do you know if there is instanceor is the newly created?
instance
self.instance.pk, , . , , .
self.instance.pk
, BaseModelForm Django 1.2, self.instance._adding, True, False . , YMMV.
self.instance._adding
, , ModelForms - , , .
Source: https://habr.com/ru/post/1796170/More articles:Fast reading of 10,000 binary files? - pythonHow to find the smallest calculation value based on multiple variables? - coldfusionhow to simulate a partial view in asp.net? - asp.netPHP Youtube Data Api loading from another domain - phpGood java tokenizers? - javaSybase stored procedure - how do I create an index on #table? - sqlTexture Management OpenGL - game-engineЗахват SQL-инъекций в классической форме asp-reposting ставит множество тиков - asp-classichttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1796174/how-do-i-clone-a-github-repository-and-auto-overwrite-existing-contents&usg=ALkJrhjb9gMUM_eR3vmUIqYf8Cl0pBTJawWhy does RTTI optimization slow down? - optimizationAll Articles