Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Many-To-Many Fields View on Django Admin

Tags:

django

Basically I am trying to recreate a fields in this model that is similar to django user authenticate system, for this I try using many-to-many fields but it ended up like this.

enter image description here

I am trying to have another field that can show what exist and another field for I have chosen similar to django admin, which looks like this.

enter image description here

This is my code

class Category(models.Model):
    name = models.CharField(max_length=128, unique=True)

class BlogPage(models.Model):
    category = models.ManyToManyField(Category)
    title = models.CharField(max_length=128)
    preview = models.TextField(max_length=256)
    content = models.TextField()
like image 968
Nameless Avatar asked Sep 10 '14 22:09

Nameless


Video Answer


1 Answers

I believe what you want is a filter_horizontal widget used in the Admin template. This should help: Django Admin ManyToManyField

like image 131
souldeux Avatar answered Sep 20 '22 03:09

souldeux