With your solution there might be a problem since name of salas is not unique. So, if you filter by the name of the sala expecting to find one and only one sala, that might not happen.
I advice you to do:
if sala in beer.salas_set.all():
#do stuff:
else:
# do other stuff
that way, beer.salas_set.all()
will return a QuerySet in which you can check if a specific object is there with the 'in' keyword.
UPDATE: as noted in the comments, you might not want to use .all()
since it's expensive. Use .exists()
instead. Thanks to @illagrenan