Catching exception if a db exists but collection does not using django-mongodb

125 views Asked by At

I am using django-mongodb engine for a django app that have multiple databases. Lets say I have a model named as Profiles. For selecting model values from correct db, I query it liked Profiles.objects.using(db_name). There are two cases for catching exceptions here. a) Db does not exists. b) Collection in that db does not exists for this model. Some exception at the time of db creation can lead to this state.

What is the best way to handle exceptions in case of these two conditions. I need to catch both exceptions separately to log different messages.

0

There are 0 answers