Currently it is not possible to put the language field directly on the user model because the get_default_language() function expects to find it on a related model of the one specified in PINAX_NOTIFICATIONS_LANGUAGE_MODEL. I'm referring to this part of the code:
|
language = model._default_manager.get(user__id__exact=user.id) |
While I understand the reasoning for this, I think it would be useful to also look for the language in the user model directly. Something like:
model = settings.PINAX_NOTIFICATIONS_GET_LANGUAGE_MODEL()
try:
language = model._default_manager.get(user__id__exact=user.id)
except FieldError: # maybe we're using custom a user model?
language = getattr(model, "language", None)
If this is not acceptable, adding FieldError to the tuple of exceptions which are caught would at least allow the function to still complete without error.
This would cater for use cases where the user model has been extended with additional fields.
Currently it is not possible to put the
languagefield directly on the user model because theget_default_language()function expects to find it on a related model of the one specified inPINAX_NOTIFICATIONS_LANGUAGE_MODEL. I'm referring to this part of the code:pinax-notifications/pinax/notifications/models.py
Line 131 in ac0fc53
While I understand the reasoning for this, I think it would be useful to also look for the language in the user model directly. Something like:
If this is not acceptable, adding
FieldErrorto the tuple of exceptions which are caught would at least allow the function to still complete without error.This would cater for use cases where the user model has been extended with additional fields.