354 | | if not getattr(settings, 'AUTH_PROFILE_MODULE', False): |
| 354 | if not getattr(settings, 'AUTH_PROFILE_MODULE', False) and ( |
| 355 | not getattr(settings, 'AUTH_PROFILE_MODULES', False)): |
| 356 | raise SiteProfileNotAvailable('You need to set AUTH_PROFILE_MOD' |
| 357 | 'ULE or AUTH_PROFILE_MODULES in y' |
| 358 | 'our project settings') |
| 359 | if getattr(settings, 'AUTH_PROFILE_MODULE', False) is not False and ( |
| 360 | getattr(settings, 'AUTH_PROFILE_MODULES', False) is not False): |
356 | | 'DULE in your project settings') |
357 | | try: |
358 | | app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.') |
359 | | except ValueError: |
360 | | raise SiteProfileNotAvailable('app_label and model_name should' |
361 | | ' be separated by a dot in the AUTH_PROFILE_MODULE set' |
362 | | 'ting') |
363 | | |
364 | | try: |
365 | | model = models.get_model(app_label, model_name) |
366 | | if model is None: |
367 | | raise SiteProfileNotAvailable('Unable to load the profile ' |
368 | | 'model, check AUTH_PROFILE_MODULE in your project sett' |
369 | | 'ings') |
370 | | self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id) |
371 | | self._profile_cache.user = self |
372 | | except (ImportError, ImproperlyConfigured): |
| 362 | 'DULE or AUTH_PROFILE_MODULES in ' |
| 363 | 'your project settings not both') |
| 364 | if getattr(settings, 'AUTH_PROFILE_MODULE', False) is not False: |
| 365 | try: |
| 366 | app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.') |
| 367 | except ValueError: |
| 368 | raise SiteProfileNotAvailable('app_label and model_name sho' |
| 369 | 'uld be separated by a dot in' |
| 370 | ' the AUTH_PROFILE_MODULE set' |
| 371 | 'ting') |
| 372 | try: |
| 373 | model = models.get_model(app_label, model_name) |
| 374 | if model is None: |
| 375 | raise SiteProfileNotAvailable('Unable to load the profi' |
| 376 | 'le model, check AUTH_PRO' |
| 377 | 'FILE_MODULE in your proj' |
| 378 | 'ect settings') |
| 379 | self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id) |
| 380 | self._profile_cache.user = self |
| 381 | except (ImportError, ImproperlyConfigured): |
| 382 | raise SiteProfileNotAvailable |
| 383 | elif getattr(settings, 'AUTH_PROFILE_MODULES', False) is not False: |
| 384 | for profile_module in settings.AUTH_PROFILE_MODULES: |
| 385 | try: |
| 386 | app_label, model_name = profile_module.split('.') |
| 387 | except ValueError: |
| 388 | raise SiteProfileNotAvailable('app_label and model_name' |
| 389 | 'should be separated by a' |
| 390 | ' dot in the AUTH_PROFILE' |
| 391 | '_MODULE setting') |
| 392 | try: |
| 393 | model = models.get_model(app_label, model_name) |
| 394 | if model is None: |
| 395 | raise SiteProfileNotAvailable('Unable to load the p' |
| 396 | 'rofile model, check ' |
| 397 | 'AUTH_PROFILE_MODULE ' |
| 398 | 'in your project sett' |
| 399 | 'ings') |
| 400 | if not hasattr(self, '_profile_cache'): |
| 401 | self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id) |
| 402 | self._profile_cache.user = self |
| 403 | else: |
| 404 | self._profile_cache.__dict__.update(model._default_manager.using(self._state.db).get(user__id__exact=self.id).__dict__) |
| 405 | except (ImportError, ImproperlyConfigured): |
| 406 | raise SiteProfileNotAvailable |
| 407 | else: |