fix logging and exception

This commit is contained in:
2025-09-10 12:32:36 +02:00
parent f6e8758541
commit f5c04f9d58
2 changed files with 6 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from lettings.models import Letting
import logging
@@ -31,6 +31,6 @@ def letting(request, letting_id):
}
print("that")
return render(request, 'lettings/letting.html', context)
except:
except ValueError:
logger.error(f"letting id : {letting_id} not found")
index(request)
return redirect('lettings_index')

View File

@@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from profiles.models import Profile
import logging
@@ -27,6 +27,6 @@ def profile(request, username):
profile = Profile.objects.get(user__username=username)
context = {'profile': profile}
return render(request, 'profiles/profile.html', context)
except:
except (ValueError, Profile.DoesNotExist):
logger.error(f"Username : {username} doesn't exist")
index(request)
return redirect('profiles_index')