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

Method save

tests/admin_inlines/models.py:58–63  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

56 title = models.CharField(max_length=50)
57
58 def save(self, *args, **kwargs):
59 while not self.rand_pk:
60 test_pk = random.randint(1, 99999)
61 if not NonAutoPKBook.objects.filter(rand_pk=test_pk).exists():
62 self.rand_pk = test_pk
63 super().save(*args, **kwargs)
64
65
66class NonAutoPKBookChild(NonAutoPKBook):

Calls 2

existsMethod · 0.45
filterMethod · 0.45