When I execulte these lines in python3 manage.py shell :
In [1]: from dream_site.models import Mentor, Mentee, Team
In [2]: a = Mentee.objects.get( pk = 1 ).name
In [3]: b = Mentor.objects.get(pk=1).name
In [4]: print( a + b )
It prints the proper output as expected, however in the models.py when I have the following code it gives me the int() argument must be a string or a number error :
def __str__(self): # Belonging to Team object
return ( str( self.pk ) + " - " + Mentor.objects.get( pk = self.mentor_id ).name + " - " + Mentee.objects.get( pk = self.mentee_id ).name )
This is the place where the error is occurring. Even though it shows these as str types in the shell.
Other parts of the models.py :
class Mentor(models.Model):
mentor_id = models.AutoField( primary_key = True )
name = models.CharField( default = '', max_length = 254 )
class Mentee(models.Model):
mentee_id = models.AutoField( primary_key = True )
name = models.CharField( default = '', max_length = 254 )
class Team(models.Model):
team_id = models.AutoField( primary_key = True )
mentor_id = models.ForeignKey( Mentor )
mentee_id = models.ForeignKey( Mentee )
team_since = models.DateTimeField( default = django.utils.timezone.now, blank = True )
__str__(self)part of?