Re: django+modelform+Foreignkey
Thanks! "It Works!" ;) 2010/3/7 Kev Dwyer : > On Sat, 06 Mar 2010 23:39:59 +0200, Arkeoloji.web.tr wrote: > >> Hi all, >> I have some ModelForms.. This ModelForms based some ForeignKey included >> models. When i want to create a ModelForm I got these ForeignKey fields >> something like (in a dropdown menu) "BlaBla object". But i want to get >> in that dropdown menus something like "Linus Torvalds". I mean how can I >> show in that fields that Models name area or adress area? >> I made my ModelForm like that : >> >> class Author(models.Model): >> name = models.ForeignKey(User) >> status = models.CharField(max_length=30) >> >> >> class AuthorForm(ModelForm): >> class Meta: >> model = Author >> exclude = ("status",) >> >> -- >> http://www.arkeoloji.web.tr > > Hello, > > Try giving your models a __unicode__ method, so that you can > manage how they are displayed. > > For example: > > class Author(models.Model): > name = models.ForeignKey(User) > status = models.CharField(max_length=30) > > def __unicode__(self): > return self.name > > Cheers, > > Kev > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- http://www.arkeoloji.web.tr -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: django+modelform+Foreignkey
On za, 2010-03-06 at 23:36 +0200, H.İbrahim Yılmaz wrote: > Hi all, > I have some ModelForms.. This ModelForms based some ForeignKey > included models. When i want to create a ModelForm I got these > ForeignKey fields something like (in a dropdown menu) "BlaBla object". > But i want to get in that dropdown menus something like "Linus > Torvalds". I mean how can I show in that fields that Models name area > or adress area? This is something you need to fix in your Model, not your ModelForm. Give the Model a __unicode__ method. -- Dennis K. The universe tends towards maximum irony. Don't push it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: django+modelform+Foreignkey
On Sat, 06 Mar 2010 23:39:59 +0200, Arkeoloji.web.tr wrote: > Hi all, > I have some ModelForms.. This ModelForms based some ForeignKey included > models. When i want to create a ModelForm I got these ForeignKey fields > something like (in a dropdown menu) "BlaBla object". But i want to get > in that dropdown menus something like "Linus Torvalds". I mean how can I > show in that fields that Models name area or adress area? > I made my ModelForm like that : > > class Author(models.Model): > name = models.ForeignKey(User) > status = models.CharField(max_length=30) > > > class AuthorForm(ModelForm): > class Meta: > model = Author > exclude = ("status",) > > -- > http://www.arkeoloji.web.tr Hello, Try giving your models a __unicode__ method, so that you can manage how they are displayed. For example: class Author(models.Model): name = models.ForeignKey(User) status = models.CharField(max_length=30) def __unicode__(self): return self.name Cheers, Kev -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
django+modelform+Foreignkey
Hi all, I have some ModelForms.. This ModelForms based some ForeignKey included models. When i want to create a ModelForm I got these ForeignKey fields something like (in a dropdown menu) "BlaBla object". But i want to get in that dropdown menus something like "Linus Torvalds". I mean how can I show in that fields that Models name area or adress area? I made my ModelForm like that : class Author(models.Model): name = models.ForeignKey(User) status = models.CharField(max_length=30) class AuthorForm(ModelForm): class Meta: model = Author exclude = ("status",) -- http://www.arkeoloji.web.tr -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
django+modelform+Foreignkey
Hi all, I have some ModelForms.. This ModelForms based some ForeignKey included models. When i want to create a ModelForm I got these ForeignKey fields something like (in a dropdown menu) "BlaBla object". But i want to get in that dropdown menus something like "Linus Torvalds". I mean how can I show in that fields that Models name area or adress area? I made my ModelForm like that : class Author class AuthorForm(ModelForm): class Meta: model = Author exclude = ("status",) -- http://www.arkeoloji.web.tr -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.