get_profile() may throw AttributeError instead of SiteProfileNotAvailable
|Reported by:||master||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I didn't find a case to fire:
except (ImportError, ImproperlyConfigured)
But some others cases :
In AUTH_PROFILE_MODULE, if:
- you don't provide a '.': 'accountsUserProfile'
- you mispell or forget the app_label part or the model_name part: 'accounts.', 'accXXXounts.UserProfile'
No exception is raised and the variable 'model' is returned as None.
==> AttributeError on following line: 'NoneType' object has no attribute '_default_manager'
I needed something similar for my own code, that I wrote as:
try: ... model = ... if not model: raise SiteProfileNotAvailable ... except ValueError: raise SiteProfileNotAvailable
Change History (6)
comment:1 Changed 6 years ago by russellm
- milestone set to 1.2
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
Changed 6 years ago by brutasse
comment:4 Changed 6 years ago by anonymous
- Resolution set to fixed
- Status changed from new to closed