2

I had the following: (it worked as expected)

# In <..>/profile/models.py
class UserProfile()
#In settings.py
AUTH_PROFILE_MODULE = "profile.UserProfile"

I have the following: (not working)

# In <..>/profile/models/__init__.py
class UserProfile()
AUTH_PROFILE_MODULE = "profile.UserProfile"

It seems that get_profile() calls get_model which is looking for models.py as a file and trys to load it.

Here is the error:

raise SiteProfileNotAvailable('Unable to load the profile ' SiteProfileNotAvailable: Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settings

The reason is that I have lot of classes in the profile app and they are all in different files and imported in:

<..>/profile/models/__init__.py

This works for everything else but the get_profile().

Any hint of a workaround?

Val Neekman
  • 17,692
  • 14
  • 63
  • 66
  • You mentioned that you have moved AUTH_PROFILE_MODULE = "profile.UserProfile" to the module <..>/profile/models/__init__.py but did you also keep one in the settings.py module? import settings and see if settings.AUTH_PROFILE_MODULE is defined and has the value you expect. – Meitham Feb 01 '12 at 12:41

1 Answers1

5

sometimes django will get confused about appnames, so make sure you have:

class UserProfile(Model):
    ....
    class Meta:
        app_label = 'profile'

This will make sure the profile can be looked up with profile.UserProfile

Thomas
  • 11,757
  • 4
  • 41
  • 57