| | 28 | |
| | 29 | def get_profile(self): |
| | 30 | """ |
| | 31 | Returns profile for this site. Raises |
| | 32 | SiteProfileNotAvailable if this site does not allow profiles. |
| | 33 | """ |
| | 34 | if not hasattr(self, '_profile_cache'): |
| | 35 | from django.conf import settings |
| | 36 | if not settings.SITE_PROFILE_MODULE: |
| | 37 | raise SiteProfileNotAvailable |
| | 38 | try: |
| | 39 | app_label, model_name = settings.SITE_PROFILE_MODULE.split('.') |
| | 40 | model = models.get_model(app_label, model_name) |
| | 41 | self._profile_cache = model._default_manager.get(site__id__exact=self.id) |
| | 42 | except (ImportError, ImproperlyConfigured): |
| | 43 | raise SiteProfileNotAvailable |
| | 44 | return self._profile_cache |