Re: Foreign Key + Primary key

2012-12-28 Thread vicherot
Well, i was looking for some help to this particulary problem... what Sandy 
want to do its callit "Generalization".  Its use full for Generalize o 
Specialize models... look 
http://packages.python.org/djeneralize/terminology.html for a example... in 
Django you must to use "inheritance" of models or even 
http://packages.python.org/djeneralize/index.html

See ya

El miércoles, 8 de febrero de 2012 14:57:34 UTC-3, akaariai escribió:
>
> On Feb 8, 7:01 pm, Sandeep kaur  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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fGmLrZL6clAJ.
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.



Re: Foreign Key + Primary key

2012-02-08 Thread akaariai
On Feb 8, 7:01 pm, Sandeep kaur  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.



Re: Foreign Key + Primary key

2012-02-08 Thread yati sagade
Even if there was provision for that(I don't know), it really wouldn't make
sense. A parent relation tuple can be referenced by multiple child relation
tuples - thereby breaking the uniqueness constraint that comes with a
primary key.

On Wed, Feb 8, 2012 at 10:31 PM, Sandeep kaur  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)
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> 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.
>
>


-- 
Yati Sagade 

(@yati_itay )

-- 
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.



Re: Foreign Key + Primary key

2012-02-08 Thread Joel Goldstick
On Wed, Feb 8, 2012 at 12:01 PM, Sandeep kaur  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)
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> 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.
>

I'm not sure if I am reading you right but maybe you are thinking
about one to one relationship:

https://docs.djangoproject.com/en/dev/topics/db/models/#one-to-one-relationships

-- 
Joel Goldstick

-- 
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.