[Answered ]-Django ajax select add button


finally i found the solution as its written wrongly in the documentation doc,

in admin.py
you should add this code, in my cade my admin calss is orderAdmin

def get_form(self, request, obj=None, **kwargs):
    form = super(orderAdmin,self).get_form(request,obj,**kwargs)
    return form


The documentation shows the exact same text as the accepted answer.



  1. your Admin class must inherit from AjaxSelectAdmin
  2. you should use AjaxSelectAdmin as a mixin (multiple inheritance)
  3. you can insert the autoselect_fields_check_can_add in your get_form()

You should only need to do the third case if you need to implement get_form for your own other purposes. It’s better to just inherit from AjaxSelectAdmin.

The other possible explanation for why you do get an ADD icon is that you don’t have permission to add the object. autoselect_fields_check_can_add checks using Django’s standard admin permissions.

Leave a comment