简体   繁体   中英

Change default form for field in django

I'm programming an application in Django and I have a ManyToManyField in my model, this relates a User model with Event model, but when I enter in django admin, the default form for ManyToManyField show all User registered in mi DB, I can't select the user that I want select.

¿ How I can change the default form in the admin site for a select form ?

This is what i have:

在此处输入图片说明

and I want something like this:

在此处输入图片说明

Thanks :)

You should use filter_horizontal in your Admin class for this model.

That would be something like:

class EventAdmin(admin.ModelAdmin):
  filter_horizontal = ('participantes',)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM