2๐
โ
You defined the __str__
and __unicode__
methods on your Employee.Meta
class.
De-indent them four space and you should be good:
class Employee(models.Model):
employee_id = models.IntegerField(primary_key=True)
first_name = models.CharField(max_length=20, blank=True)
last_name = models.CharField(max_length=25)
email = models.CharField(unique=True, max_length=25)
phone_number = models.CharField(max_length=20, blank=True)
hire_date = models.DateField()
job = models.ForeignKey('Job')
salary = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True)
commission_pct = models.DecimalField(max_digits=2, decimal_places=2, blank=True, null=True)
manager = models.ForeignKey('self', blank=True, null=True, related_name ='employee')
department_id = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'employees'
def __str__(self):
return self.employee_id
def __unicode__(self):
return self.employee_id
๐คSimon Charette
0๐
Add __unicode__()
or __str__()
method in your Employee
model as you have done in Job
.
class Employee(models.Model):
def __unicode__(self):
return self.email #or whatever string you want
This method is used to represent objects as string in django.
๐คRohan
- [Answered ]-Django, Extend BaseUserManager,
- [Answered ]-How to make pylint recognize variable via astroid
- [Answered ]-Django: Setting initial vals of multiplechoicefield only works first time
Source:stackexchange.com