[Fixed]-Django Foreign Key and Forms

1👍

✅

__unicode__() must always return a string or unicode. Party.__unicode__() does not. To fix, convert the returned value explicitly to string: return str(self.PartyID)

0👍

Add method like this.

def __unicode__(self):
    return u"%i" % self.CheckOutID

The documentation says:

The unicode() method is called whenever you call unicode() on an object. Since Django’s database backends will return Unicode strings in your model’s attributes, you would normally want to write a unicode() method for your model.

Leave a comment