Ok thank you for your solutions :) Le 4 mai 2011 à 15:09, Xavier Ordoquy <xordo...@linovia.com> a écrit :
> > Le 4 mai 2011 à 14:56, Pascal Moutia a écrit : > >> First tank you Xavier for you respond let me get you more precisions: >> this is my app models.py (normaly the models.py have more classes always >> with a ForeignKey to Info): >> >> class Info (models.Model): >> nom = models.CharField(max_length=100) >> prenom = models.CharField(max_length=100) >> rue = models.CharField(max_length=200) >> cpostal = models.CharField(max_length=10) >> ville = models.CharField(max_length=100) >> mail = models.CharField(max_length=100) >> tel = models.CharField(max_length=100) >> #pic = models.ImageField() >> >> def __unicode__(self): >> return self.nom >> >> class Naissance(models.Model): >> info = models.ForeignKey(Info) >> date = models.DateTimeField(blank=False) >> >> def __unicode__(self): >> return self.date >> >> and my urls.py configuration for the generic view : >> >> url(r'^cv/(?P<pk>\d+)/$', DetailView.as_view( >> model = Info, >> template_name = 'Cv/cv_detail.html')), >> >> So i need to show all classes from my models.py in detailview on one >> template what could be the query set? > > You need to access the data linked to your Info model. > Say you have an Info instance named info. > You can access all the Naissance linked to info by simply doing > info.naissance_set.all() which will return an equivalent to a list of > Naissance objects. Note that in that case, it might have been better with a > OneToOneField. > > Please, have a look at the tutorial available for Django. > It explains the basics, including how to get choices linked to a poll which > is the same as what you are doing. > > Regards, > Xavier. > > -- > 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 at http://groups.google.com/group/django-users?hl=en.