Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » problem with multiple Foreignkeys in ModelForm [RSS Feed]

#1 Dec. 16, 2010 05:39:56

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

problem with multiple Foreignkeys in ModelForm

I'm getting the following error:
annot assign "<User: XXXX>": "Bid.bidder" must be a "Bidder" instance.

class Listing(models.Model):
owner = models.ForeignKey(User, verbose_name=_('Im the wanter'))
title = models.CharField(_('short description'), max_length=255)

class Bidder(models.Model):
user = models.ForeignKey(User, verbose_name=_('bidder'),

class Bid(models.Model):
listing = models.ForeignKey(Listing)
bidder = models.ForeignKey(Bidder)
bidding_price = models.DecimalField(_('offering bid',),
max_digits=6, decimal_places=2,blank=True, null=False)

class BidForm(forms.ModelForm):
class Meta:
model = Bid
exclude = ('bidder', 'listing',)
def newbid(request,listing_id):
''' Create a new bid with request.user as owner
if request.method == 'POST':
form = BidForm(request.POST)
if form.is_valid:
bidder_person=Bidder(user = request.user)

bid.bidder = bidder_person #problem is here!

l = get_object_or_404(Listing, pk=listing_id)
bid.listing = l
bid.listing.owner = l.owner
return HttpResponseRedirect(reverse('listings_all'))

form = BidForm()

return create_object(
form_class = BidForm

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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.


  • Root
  • » Django
  • » problem with multiple Foreignkeys in ModelForm [RSS Feed]

Board footer

Moderator control

Enjoy the 24th of May

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support