A friend suggested this book called “Elements of Programming Interviews in Python” to me. Interviews have always been a weak spot for me, and I am not particularly bright when it comes to hardcore coding assignments. So I took this book as an opportunity to improve myself a bit.
The book has a section called “Design Problems” where there are few systems that you have to design as an exercise. First of them is a spelling checker. I took it up and read the clues provided by them, and thought, let’s try to build one as an exercise.
It may sometime happen that to validate a form field you need to check the value with some existing value from the database related to the User or some other entity. But sadly Django doesn’t allow accessing the Request object in the clean() or clean_<FieldName>() methods. Here is a way around it -