4👍
✅
If you are using SQLite as your database, there is no alternative for ManyToManyField
.
However, if you are using (or if you switch to) PostgreSQL as your database, you’ll be able to use ArrayField
.
You can use it like this:
field_1 = ArrayField(
models.CharField(max_length=50, blank=True)
)
P.S. I assume you aren’t really going to name your fields field 1
etc., but if you do, don’t use spaces, use underscores instead, so field_1
, etc.
There is lots of information on how to use Postgres instead of SQLite, for instance this link would be a good start.
However, in most cases I would still recommend using a ManyToManyField, because it’ll enable you to easily query on shared relationships between two objects, and prevent duplicate data as well.
Source:stackexchange.com