У меня есть TabularInline
, который я добавил в класс администратора.Встроенный показывает ОК в представлении администратора, однако ссылка «Добавить еще» не отображается
Я проверил, что JS включен на 100%, так как это может быть проблемой в соответствии с Django docs.
Я также проверил, и нет никаких ошибок консоли или сетевых ошибок при загрузке любых стандартных файлов JS.
Я изменил max_num, min_num и дополнительные переменные в классе Inline, и ничего не изменилось
admin.py:
from django.contrib import admin
from django.forms.models import BaseInlineFormSet
from .models import Evaluation, MV1_test
class MV1test(admin.TabularInline):
extras=3
max_num=5
model = MV1_test
verbose_name = 'MV1 Test'
verbose_name_plural = 'MV1 Tests'
class evaluationAdmin(admin.ModelAdmin):
save_on_top=True
fieldsets=(
('General',{
'fields':(('view_link'),('rma_number','evaluation_status','customer_name','customer_email','order_number','serial_number','firmware'),('evaluator','evaluation_date','replacement'))
}),
('Visual Evaluation',{
'fields':(
('condition_heatsink',
'heatsink_notes'),
('condition_stem',
'stem_notes'),
('condition_oven',
'oven_notes'),
('condition_door',
'door_notes'),
('condition_matte_uv',
'matte_uv_notes'),
('condition_plating',
'plating_notes'),
('condition_bypass',
'bypass_notes'),
('condition_coil',
'coil_notes')),
}),
('App Evaluation',{
'fields':(
('ghost_app_connection','ghost_app_connection_notes'),
('ble_connection', 'ble_connection_notes'),
('firmware_update_connection','firmware_update_connection_notes')
)
}),
('Haptic Evaluation',{
'fields':(
('vape_button_haptic','vape_button_haptic_notes'),
('power_button_haptic', 'power_button_haptic_notes'),
)
}),
('Battery Evaluation',{
'fields':(
('usb_charge','usb_charge_notes'),
('fast_charger_charge', 'fast_charger_charge_notes'),
('battery_removal','battery_removal_notes')
)
}),
('Over Door Evaluation',{
'fields':(
('door_sensor','door_sensor_notes'),
('latch_spring', 'latch_spring_notes'),
('oven_door','oven_door_notes'),
)
}),
('Performance',{
'fields':(
('taste_performance','taste_performance_notes'),
('odor_performance', 'odor_performance_notes'),
)
}),
('ABV',{
'fields':(
('abv_pic',
'abv_thumbnail'),
('abv_notes'),
)
}),
('Evaluation Summary',{
'fields':(
('evaluation_summary'),
)
})
)
inlines=[MV1test]
search_fields = ('serial_number', 'customer_name','customer_email','evaluator__username')#__username means look up the field from the FK
list_filter=['evaluation_date','evaluator']
list_display=('rma_number','serial_number','evaluator','customer_name','customer_email','replacement')
def get_readonly_fields(self, request, obj=None):
if obj: # obj is not None, so this is an edit
return ['evaluator','abv_thumbnail','evaluation_date','view_link'] # Return a list or tuple of readonly fields' names
else: # This is an addition
return ['abv_thumbnail','view_link']
admin.site.register(Evaluation, evaluationAdmin)
Я ожидаю увидеть ссылку «Добавить еще» под встроенным разделом (в представлении администратора), но ссылки нет.Также, если я установлю extra = 3, должно появиться 3 экземпляра inline, но появляется только 1:
Как выглядит inline в admin
With extra
установлен на 3, должно быть не менее 3-х строк, отображаемых в виде