[Fixed]-Django: How to properly use the ForeignKey in a modelform?

1👍

Use __unicode__ for your accounts class:

class accounts(models.Model):
    name = models.CharField(max_length=200)
    url = models.CharField(max_length=200)

    def __unicode__(self):
        return self.name

By the way, it’s bad code style to use accounts as python class name. It should be capfirst and single form like Account. Check pep8 doc for convention details.

Leave a comment