Re: Django OneToOne field problem

2014-06-12 Thread Max Demars
You will have to do content.link_set to retrieve the Link model related to 
the Content model instance.

See: 
https://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

On Thursday, June 12, 2014 2:54:48 PM UTC-4, Satinderpal Singh wrote:
>
> Suppose there are two tables defined in Django models: 
>
> class Link(models.Model): 
> links = models.CharField(max_length=50 ,blank=True) 
>
> and 
>
> class Content(models.Model): 
> link = models.OneToOneField(Link, primary_key=True) 
> title = models.CharField(max_length=50, blank=True) 
> content = models.CharField(max_length=1000, blank=True) 
> footer = models.CharField(max_length=150, blank=True) 
>
> In the above table "Content" the OneToOne field contains the Link.id 
> attribute of the 
> table"Link", but how could i get it as, Link.links. 
>
> -- 
> Satinderpal Singh 
> http://satindergoraya91.blogspot.in/ 
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b52e144-ef71-4753-8e2e-8c57c9a20a6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django OneToOne field problem

2014-06-12 Thread Satinderpal Singh
Suppose there are two tables defined in Django models:

class Link(models.Model):
links = models.CharField(max_length=50 ,blank=True)

and

class Content(models.Model):
link = models.OneToOneField(Link, primary_key=True)
title = models.CharField(max_length=50, blank=True)
content = models.CharField(max_length=1000, blank=True)
footer = models.CharField(max_length=150, blank=True)

In the above table "Content" the OneToOne field contains the Link.id
attribute of the
table"Link", but how could i get it as, Link.links.

-- 
Satinderpal Singh
http://satindergoraya91.blogspot.in/

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BiK19JdAFVEeidBmOLFz7Pjn6c9sgBbMb33%2BC%2BNkNpiQ%3DRnGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.