plafhz
plafhz

Reputation: 781

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:

enter image description here

and I want something like this:

enter image description here

Thanks :)

Upvotes: 1

Views: 234

Answers (1)

Kirill Bubochkin
Kirill Bubochkin

Reputation: 6343

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

That would be something like:

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

Upvotes: 2

Related Questions