On Sun, 7 Apr 2013 17:01:52 -0700 (PDT) frocco <faro...@gmail.com> wrote:
> I have a model that references User and on the admin page, it shows the > user name. > I have the User tied to a UserProfile model that has a field called > company. > > I want the drop down on my Pricing Model to show company, not user. > > user = models.ForeignKey(User) > Possibly something like this in your forms.py #forms.py class PricingForm(forms.ModelForm): class Meta: model = PricingModel def __init__(self, *args, **kwargs): super(PricingForm, self).__init__(*args, **kwargs) self.fields['user'].choices = ((c.id,c.company) for c in UserProfile.objects.all()) or specify the choice in your model like this user = models.ForeignKey( User, help_text='Select the user to apply this pricing', choices=((c.id,c.company) for c in UserProfile.objects.all()) ) -- Drew
signature.asc
Description: PGP signature