1

I am having a validation error when I set a random string in my url as token. How can i catch this validation error?

For example: when accesing: https://www.example.com/stream/8e258b27-c787-49ef-9539-11461b251ffad

The error is ValidationError at /stream/8e258b27-c787-49ef-9539-11461b251ffad ['“8e258b27-c787-49ef-9539-11461b251ffad” is not a valid UUID.']

my code is this:

def stream(request, token):
user = Creador.objects.filter(stream_token=token).first()
if user:
    return render(request, 'app1/stream.html', {
        'token':token, 'user':user
    })
else:
    return HttpResponse("Token no existe")

any ideas? thanks

deloco
  • 43
  • 8
  • Does this answer your question? [How to determine if a string is a valid v4 UUID?](https://stackoverflow.com/questions/19989481/how-to-determine-if-a-string-is-a-valid-v4-uuid) – iklinac Jan 30 '21 at 23:21
  • @iklinac unluckily it doesnt :( – deloco Jan 30 '21 at 23:39
  • 1
    what exactly is unclear to you, in your provided code you do not set anything also your random string is not valid UUID. Please do provide https://stackoverflow.com/help/minimal-reproducible-example – iklinac Jan 30 '21 at 23:42

0 Answers0