[Fixed]-Change the keys in Django ModelChoiceField when populated from a ForeignKeyField

1👍

Add __str__(__unicode__ for Python2.x) method to your customer model:

class customer(models.Model):
    custid = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30)
    email = models.EmailField(max_length=245)
    address = models.CharField(max_length=50)
    state = models.CharField(max_length=2)
    zip = models.CharField(max_length=5)
    phone = models.CharField(max_length=13)

    def __str__(self):  # __unicode__ for python2.x
        return self.name
👤pythad

Leave a comment