Thanks Drew,

I am trying your second suggestion.

But it is complaining not found for UserProfile

On Sunday, April 7, 2013 8:41:46 PM UTC-4, Drew Ferguson wrote:
>
> On Sun, 7 Apr 2013 17:01:52 -0700 (PDT) 
> frocco <far...@gmail.com <javascript:>> 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 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to