I have next django code
models.py
class Service(models.Model):
username = models.CharField(...)
password = models.CharField(...)
...
class Order(models.Model):
service = models.ForeignKey('Service', on_delete=models.CASCADE, related_name='orders')
number = models.CharField(...)
creation_date = models.DateTimeField(...)
...
admin.py
@register(Service)
class ServiceAdmin(ModelAdmin):
class OrderNewInline(TabularInline):
'''
Display orders from remote service, external api, data-file ...
List of orders to be imported
'''
model = Order
extra = 0
can_delete = False
def has_change_permission(self, request, obj=None):
return False
def has_add_permission(self, request, obj=None):
return False
# Getting orders from remote service, external api, data-file ...
# @param Service service - current service model instance
# @return list - list of external orders
def get_data(self, service, ...):
...
class OrderInline(TabularInline):
'''
Display orders already imported
'''
model = Order
...
inlines = [OrderNewInline, OrderInline]
Please help me find solutions to the following questions:
- How to display orders in
OrderNewInline
from remote service, external api, data-file … - Create column in
OrderNewInline
with checkbox for mark orders have to be imported - Add a button to
OrderNewInline
form to trigger orders import event