Sure - you can...
ModelAdmin specific method: (the other methods are in my answer in the post linked to above)
class MyModelAdmin(admin.ModelAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "school":
kwargs["queryset"] = School.objects.order_by('name')
return super(MyModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
Examples for the other 3 non admin specific methods in my post linked above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…