AUTH_PROFILE_MODULE should be able to provide some default profile
|Reported by:||Owned by:|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently if there are users without a profile in the database django raises an DoesNotExist-exception. This exception has to be cought everywhere some application wants to access the profile, which leads to a lot of duplicate code...at least if you use the profile a lot inside your project.
This could easily be fixed by adding some way to auto-create a default profile if necessary and possible. One suggestion might be defining some API that could be called, for example:
- The model (or model-manager) provides some method, that could be called if the profile does not exist
- Otherwise the DoesNotException gets raised like before
I propose changing User.get_profile() so it supports such an API. Patch using model._default_manager.create_default_profile() follows.