Use a many-to-many field instead.
https://docs.djangoproject.com/en/2.0/topics/db/models/#many-to-many-relationships


From: [email protected] [mailto:[email protected]] On 
Behalf Of Hasanul Islam
Sent: Tuesday, December 26, 2017 9:52 AM
To: Django users
Subject: How to store multiple object reference in one field?

Suppose, I have a model
                class Project(models.Model):
                        name = models.CharField(max_length=50)
Another model,
               class Manager(models.Model)
                         name = models.CharField(max_length = 50)
                         projects = ArrayField( models.Foreignkey(Project, 
on_delete=models.PROTECT) )

Here, projects field would be an array of Project object. But it is PostgreSQL 
specific. How can I implement this so that it will be useful for every database?
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1f3a4691-fb23-4a42-9387-ea67562635c3%40googlegroups.com<https://groups.google.com/d/msgid/django-users/1f3a4691-fb23-4a42-9387-ea67562635c3%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ca4ccae24404cea8643dccc6c42fef3%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to