Answer the question
In order to leave comments, you need to log in
Django, InlineModelAdmin.get_extra error, what's the problem?
Hello, the problem is this, it was necessary to return the number of additional built-in forms, I took this code from the documentation
class BinaryTreeAdmin(admin.TabularInline):
model = BinaryTree
def get_extra(self, request, obj=None, **kwargs):
extra = 2
if obj:
return extra - obj.binarytree_set.count()
return extra
class Jurnal(models.Model):
pos = models.AutoField(unique=True, primary_key=True)
client = models.ForeignKey(Client, on_delete=models.CASCADE, db_column='client_id',)
data = models.DateField(default=date.today, blank=True, null=True)
time = models.TimeField(default=datetime.datetime.now, blank=True)
class JurnalInline(admin.TabularInline):
model = Jurnal
def get_extra(self, request, obj=None, **kwargs):
extra = 5
if obj:
return extra - obj.jurnal_set.count()
return extra
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question