When using Django get_or_create () when created = True, is there a way to make it create an object without saving it to the database?
I want to take the newly created object, perform some checks, and only save it to the database if it passes all the tests.
Instead of trying to force get_or_create to do something wrong, why not just create a new @classmethod method (or use a user manager) called get_or_new () and then only save () if you want?
? .
class MyModel(Model) def save(self): self.run_presave_tests() if self.passed_tests: super(MyModel, self).save()
Source: https://habr.com/ru/post/1725648/More articles:Running selenium tests through JUnit in Hudson - javaC # Anonymous Type - c #Fix current dirty cell when pressing save button from any datagridview document in form - c #Captured Image UIView Has Distorted Colors (iPhone SDK) - iphonechecking if any particular element exists or not in the STL C ++ vector - c ++Inheriting from a virtual template class in C ++ - c ++1-n ratio - databaseUIPageControl key to scroll? - iphoneHow to assign an empty matrix to elements of an array of cells in MATLAB? - indexingShould I support SerialPort connection? - .netAll Articles