Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 18, 2011 09:01:11

Praveen K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ForeignKey to User


*Hi,*
*
*
*Could any of you tell me about the things which I should take care while
defining a *
*foreign key to User model. ? *
*
*
*Do I need to define the related_name ='+' as it says in the documentation?
and what does it do?*
*

user = models.ForeignKey(User, related_name='+')

*
--
*Praveen Krishna R*

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 18, 2011 11:47:14

Ivo B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ForeignKey to User


from the docs:

If you'd prefer Django didn't create a backwards relation, set related_name to
'+'. For example, this will ensure that the Usermodel won't get a backwards
relation to this model:

If your Model is called: MyModel then you could do for a user instance:

user.mymodel_set , but if you define a '+’ as related_name, you can’t because
django does not create the ‘reverse relationship’




On 18.01.2011, at 10:00, Praveen Krishna R wrote:

> Hi,
>
> Could any of you tell me about the things which I should take care while
> defining a
> foreign key to User model. ?
>
> Do I need to define the related_name ='+' as it says in the documentation?
> and what does it do?
>
> user = models.ForeignKey(User, related_name='+')
>
> --
> Praveen Krishna R
>
>
> --
> 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.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 18, 2011 12:04:02

Praveen K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ForeignKey to User


*Thank You
*
On Tue, Jan 18, 2011 at 12:08 PM, Ivo Brodien <i...@brodien.de> wrote:

>
> from the
> docs<http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name>
> :
>
> If you'd prefer Django didn't create a backwards relation, set
> related_name to '+'. For example, this will ensure that the Usermodel
> won't get a backwards relation to this model:
>
> If your Model is called: MyModel then you could do for a user instance:
>
> user.mymodel_set , but if you define a '+’ as related_name, you can’t
> because django does not create the ‘reverse relationship’
>
>
>
>
> On 18.01.2011, at 10:00, Praveen Krishna R wrote:
>
> *Hi,*
> *
> *
> *Could any of you tell me about the things which I should take care while
> defining a *
> *foreign key to User model. ? *
> *
> *
> *Do I need to define the related_name ='+' as it says in the
> documentation? and what does it do?*
> *
>
> user = models.ForeignKey(User, related_name='+')
>
> *
> --
> *Praveen Krishna R*
>
>
> --
> 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.
>
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>



--
*Praveen Krishna R*

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 18th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support