TabularInline

32 views
Skip to first unread message

Tolga ÇAĞLAYAN

unread,
Jul 29, 2023, 9:32:51 PM7/29/23
to Django users
This is what tabularinline looks like. I want a table here instead. I want it to work like normal CRUD. Anyone have an idea about this? 

I don't want that
Ekran görüntüsü 2023-07-29 214456.png
I  want like this
Ekran görüntüsü 2023-07-29 214733.png

Parthian

unread,
Jul 30, 2023, 12:15:17 PM7/30/23
to Django users
Try this
class YourModelInline(admin.TabularInline):
    model = YourModel
    fields = ('fields', )
    extra = 0 # looks neater without extras.
    show_change_link = True # puts an icon on the left of each row to edit the row.

    def has_change_permission(self, request, obj=None):
        return False # MAKES EVERYTHING READONLY. AWESOME.
    def has_delete_permission(self, request, obj=None):
        return False # option
    def has_add_permission(self, request, obj=None):
        return False # option

Tolga ÇAĞLAYAN

unread,
Jul 30, 2023, 12:33:55 PM7/30/23
to Django users
Yes, it looks like this table. But how do I make an insertion, deletion, edit here in the normal way. When I press the Add button, I want the page to open to add data here. Thanks for your answer


30 Temmuz 2023 Pazar tarihinde saat 18:15:17 UTC+2 itibarıyla Parthian şunları yazdı:

Parthian

unread,
Jul 30, 2023, 12:51:42 PM7/30/23
to Django users
If I understand you wish to have a readonly table view which switches inline to a 'normal' edit view.
I wonder if you could set - has_change_permission back to True in some way?
Could be handy. If you figure it out post here.

Tolga ÇAĞLAYAN

unread,
Jul 30, 2023, 1:07:37 PM7/30/23
to Django users
I want it to look like normal model.Admin. I want add, edit and delete to work normally. Tabularinline gets very confusing when you enter 100 pieces of data.
I want it to work like below

Ekran görüntüsü 2023-07-29 214733.png

30 Temmuz 2023 Pazar tarihinde saat 18:51:42 UTC+2 itibarıyla Parthian şunları yazdı:
Reply all
Reply to author
Forward
0 new messages