I'm not sure what you are trying to achieve, but you probably don't want all of the models to use the same primary key. You can access the primary key though via the pk or id attributes. For instance: Grade.objects.all().values("subjt_id", "subjt__pk", "subjt__profile_id", "subjt__profile__pk")
However, I am not sure what you are trying to do.

Hope that helps!

On 2/16/2018 7:28 AM, dahlen.llo...@gmail.com wrote:
Ok, thanks for replying. am quite new in Django. Am looking for a way to use a primary key in 3 models in my django project. for instance. The models are Profile, Subject and Grade. Want subject to link to profile and grade to link to subject. class Profile(models.Model): f_name = models.CharField(max_length=20) l_name = models.CharField(max_length=20) sch_id = models.CharField(max_length=20) class Subject(models.Model): profile = models.ForeignKey(Profile, on_delete=models.CASCADE) maths = models.CharField(max_length=20) english = models.CharField(max_length=20) class Grade(models.Model): subjt = models.ForeignKey(Subject, on_delete=models.CASCADE) score = models.CharField(max_length=20) grad = models.CharField(max_length=20)
I don't know to archive this.
--
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+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/5febac08-6b1f-4c8a-a067-6abaf3f162a3%40googlegroups.com <https://groups.google.com/d/msgid/django-users/5febac08-6b1f-4c8a-a067-6abaf3f162a3%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
This message has been scanned for viruses and dangerous content by
*E.F.A. Project* <http://www.efa-project.org>, and is believed to be clean. Click here to report this message as spam. <http://lsefa1.linear-systems.com/cgi-bin/learn-msg.cgi?id=54E00100068.A372D&token=397ef044a75dff3ae2280e070d1b1541>


--
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+unsubscr...@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/efe4f2c4-af50-ce96-053e-1d97e010a9f2%40linear-systems.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to