Tuesday, December 26, 2017

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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment