On Feb 8, 7:01 pm, Sandeep kaur <mkaurkha...@gmail.com> wrote:
> Is there any way of having a field in table, declared both as foreign
> key as well as primary key?
> I want something like this in models:
>      publisher = models.ForeignKey(Publisher,primary_key=True)

If the above doesn't work, then I guess the answer is no.

You could probably do:
      publisher = models.ForeignKey(Publisher, unique=True)
which is at least somewhat close to what you wanted. You will have an
extra column for the PK, but otherwise this should function pretty
close to having the ForeignKey as PK.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to