compsite key

16 views
Skip to first unread message

narendra thapa

unread,
Oct 4, 2019, 7:47:37 AM10/4/19
to Django users
as i was trying to make a composite key on students model . i wanna make composite key of field enrolled year and roll no but django is not accepting a two primary key in same model

Jani Tiainen

unread,
Oct 4, 2019, 10:24:02 AM10/4/19
to django...@googlegroups.com
Hi.

Django doesn't support composite keys.


pe 4. lokak. 2019 klo 14.47 narendra thapa <narendra...@gmail.com> kirjoitti:
as i was trying to make a composite key on students model . i wanna make composite key of field enrolled year and roll no but django is not accepting a two primary key in same model

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ae2576ec-e3ae-4ec6-bbf0-e93e1965378e%40googlegroups.com.

Jagadesh Babu T

unread,
Oct 4, 2019, 10:34:14 AM10/4/19
to django...@googlegroups.com
Django doesn’t support composite primary key as the ORM heavily relies on a single attribute of a class(e.g: pk or id) field for its inference and usage in the django applications. Owing to this reason composite primary keys are not permitted in Django. But you may use unique_together constraint on the field if that fits your bill.

On Fri, 4 Oct 2019 at 5:16 PM, narendra thapa <narendra...@gmail.com> wrote:
as i was trying to make a composite key on students model . i wanna make composite key of field enrolled year and roll no but django is not accepting a two primary key in same model

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ae2576ec-e3ae-4ec6-bbf0-e93e1965378e%40googlegroups.com.
--
Warm Regards
Jagadesh
Reply all
Reply to author
Forward
0 new messages