[Answer]-Displaying "info" by selecting foreign key in django admin

1πŸ‘

βœ…

It sounds to me like you want an employee to be able to use the admin site to create an employee order from a customer order. I think it could be as simple as adding a raw ID field for the customer order. That is, I think you can just change EmployeeOrderAdmin like so:

class EmployeeOrderAdmin(admin.ModelAdmin):
    list_display = ('employee_order_date', 'employee_placed')
    raw_id_fields = ('order',)

Now when an employee creates an employee order, they will be able to use the OrderAdmin page to find the order they want.

Additionally, suppose you want that pop-up window to display the orders in a particular way. In that case, keep in mind that requests to display that pop-up window will contain an additional GET parameter called pop. You could:

class OrderAdmin(admin.ModelAdmin):
    def queryset(self, request):
        qs = super(ActiveOfferAdmin, self).queryset(request)
        if request.GET.get('pop'):
            return qs.order_by(...)
        return qs

Leave a comment