5
Don’t try to make Django return a nice response in the case of a syntax error. That will be difficult, and will involve having code of your own just for this case, and that code itself will need to be error-free, etc.
Instead, put that effort into an automated test suite that will make it easy to find those errors before you deploy your code.
2
Syntax errors can be detected trivially as you don’t need to run the code but only to import it.
There’s no reason you should try to catch them, just fix them.
- [Django]-How frequently should Python decorators be used?
- [Django]-Django Hierarchy Permissions
- [Django]-Add E-Mail header in django
- [Django]-Django – Custom Template Tag passing keyword args
0
You can catch syntax (And Indentation) errors out of your code.
Look here for more info:
How to catch IndentationError
- [Django]-Django Private Project Git Repo – Open Source App Repo
- [Django]-Django: how to map the results of a raw sql query to model instances in admin list view?
- [Django]-How should error corresponding to an AJAX request be passed to and handled at the client-side?
0
Syntax errors are not run time errors, they occur at compile time. As far as I know, you can’t catch them with a try/except block.
- [Django]-Xapian search terms which exceed the 245 character length: InvalidArgumentError: Term too long (> 245)
- [Django]-Errno 13 Permission denied Django Upload File
- [Django]-Running django application via SSH on Windows
- [Django]-Django serializer ManyToMany retrun array of names instead of an array of IDs