Hi King Niko,
On 02/09/2020 17.46, King Niko wrote:
> *I have not managed to get the Django log up and running, but this may
> help to get guidance on resolving the issue:*
>
You should get access to the Django log. It's pointless to waste time on
guessing what might be wrong when you could have a log file pointing you
to exactly the line of code which is the cause of your error.
Anyway, regarding your code:
> try:
> cart = json.loads(request.COOKIES['cart'])
> except:
Only catch the exceptions you actually expect to be thrown and know how
to handle. Catching all potential exceptions like you're doing here will
potentially silence a lot of errors making it much harder for you to
debug any issues that might occur later on because you ignored the
original error.
> except:
> pass
This is even more problematic. Here you are simply ignoring any
exceptions that might be thrown again making it extremely hard to debug
since you'll just get exceptions or "weird" behavior later on.
Instead of trying to guess what might be wrong, you're lucky enough to
be using an interpreted language (Python) that can give you some very
precise error messages if you stop ignoring the errors and get access to
the logs which will show exactly what went wrong.
Kind regards,
Kasper Laudrup
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/76612162-ff10-06ea-84e5-8a52a31e45e6%40stacktrace.dk.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment