[Answered ]-Django : ManyToMany relation error ( object has no attribute)

1👍

The class PerfumeBrand never defines the variable person, only name.

👤tactic

1👍

On the PerfumeBrand object, you have declared this

def __str__(self):
    return self.person.first_name + ' ' + self.person.last_name.upper() + ': ' + self.name

But person is not an attribute of PerfumeBrand. That function should be under the Person class (with some changes before) and you should use something like the following in the PerfumeBrand class:

def __str__(self):
    return self.name
👤VMRuiz

Leave a comment