M
M
Mooris2017-05-01 18:54:57
Django
Mooris, 2017-05-01 18:54:57

Django how to return a certain number of forms from a model?

Hello, how to return a certain number of forms from a model?
let's say when editing we have n - the number of added records, how to return, for example, only the last 3

admin.py

class JurnalInline(admin.TabularInline):
    model = Jurnal
    extra = 1

class ClientAdmin(admin.ModelAdmin):
    inlines = [JurnalInline]


3cebb4c9d1d849ee9313b313be13afea.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-05-01
@sergey-gornostaev

Set sorting and limit quantity :

class JurnalInline(admin.TabularInline):
    max_num = 3
    ordering = ['-data_poseshenia']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question