Skip to content

Instantly share code, notes, and snippets.

@tacianosilva
Last active April 26, 2020 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacianosilva/d3d8f22b80bb5b810cdd4fd3cd0d4bac to your computer and use it in GitHub Desktop.
Save tacianosilva/d3d8f22b80bb5b810cdd4fd3cd0d4bac to your computer and use it in GitHub Desktop.
def get_horarios_str(self):
ret = ''
print(self.horarios.all())
# use models.ManyToMany field's all() method to return all the Department objects
# that this employee belongs to.
for horario in self.horarios.all():
ret = ret + horario.__str__() + ','
# remove the last ',' and return the value.
return ret[:-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment