On Mon, Jul 4, 2011 at 11:12 AM, Szabo, Patrick (LNG-VIE) <patrick.sz...@lexisnexis.at> wrote: > Hi, > > > > I have a forum that looks like this: > > > > class ReportingForm_Produkt(ModelForm): > > class Meta: > > model = Buchung > > > > Where Buchung and Produkt looks like this: > > > > class Buchung(models.Model): > > Mitarbeiter = models.IntegerField(max_length=3) > > Produkt = models.ForeignKey(Produkte) > > Datum = models.DateField() > > Aktivitaet = models.ForeignKey(Aktivitaeten, blank=True) > > Minuten = models.PositiveIntegerField(max_length=2) > > > > def __unicode__(self): > > return str(self.Mitarbeiter) + ' ' + str(self.Datum) > > > > class Meta: > > db_table = 'tb_Times' > > verbose_name_plural = "Buchungen" > > verbose_name = "Buchung" > > > > class Produkte(models.Model): > > Kategorie = models.ForeignKey(Kategorien) > > Titel = models.CharField(max_length=100) > > Auflage = models.IntegerField(max_length=2, default=0) > > Bestell_Nr = models.CharField(max_length=30, blank=True) > > ISBN = models.CharField(max_length=30, blank=True) > > Autor = models.CharField(max_length=50, blank=True) > > Status = models.IntegerField(max_length=1, blank=False, default=1) > > > > def __unicode__(self): > > if self.Auflage: > > return "%s %s" % (self.Titel, self.Auflage) > > else: > > return self.Titel > > > > class Meta: > > db_table = 'tb_Produkte' > > verbose_name_plural = "Produkte" > > verbose_name = "Produkt" > > unique_together = ("Kategorie", "Titel", "Auflage", "Status") > > > > Now if i include that form into a template, the dropdown only shows the > „Titel“ of each objects from „Produkte“. I also want the „Auflage“ – Info > to be visible in the drop down. > > > > How do i do that ?! > > > > greetings >
https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelchoicefield """ The __unicode__ method of the model will be called to generate string representations of the objects for use in the field's choices; to provide customized representations, subclass ModelChoiceField and override label_from_instance. """ Cheers Tom -- 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.