avoid getting mails for get_object_or_404 failures

main
Laurent 2 days ago
parent a31796aad0
commit cf28db9fd0
  1. 8
      tournaments/views.py

@ -69,6 +69,12 @@ from .models import AnimationType
logger = logging.getLogger(__name__)
def get_object(type, id):
try:
return type.objects.get(pk=id)
except (type.DoesNotExist, ValueError, ValidationError):
raise Http404(f"{type.__name__} does not exist")
def index(request):
now = timezone.now()
thirty_days_ago = now - timedelta(days=30)
@ -118,7 +124,7 @@ def tournaments_query(query, club_id, ascending, limit=None):
club = None
if club_id:
club = get_object_or_404(Club, pk=club_id)
club = get_object(Club, club_id)
q_club = Q(event__club=club)
queries.append(q_club)
else:

Loading…
Cancel
Save