Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango decorator generates SiteProfileNotAvailable error
    text
    copied!<p>Newbie to Python (2.6) and Django (1.2) here, learning the ropes. Consider the following decorator that I want to use on methods, along with @login_required, that redirects users to a profile completion url if they try and do something that requires a "minimum information supplied" profile.</p> <p>The usage pattern is intended to be:</p> <pre><code>@login_required @min_profile_required def my_view(request): # do whatever. </code></pre> <p>My current defintion of the min_profile_required decorator is as follows:</p> <pre><code>def min_profile_required(decorated_view): @wraps(decorated_view) def redirector(request, *args, **kwargs): if ProfileHelper.is_min_profile_complete(request.user): return decorated_view(request, *args, **kwargs) return HttpResponseRedirect(PROFILE_COMPLETION_URL) return redirector </code></pre> <p>To me, this feels like a bit of Python 101, but Django doesn't like it at all. The following error is generated</p> <pre><code>SiteProfileNotAvailable at ... app_label and model_name should be separated by a dot in the AUTH_PROFILE_MODULE setting </code></pre> <p>The decorator is part of an "accounts" application, so the AUTH_PROFILE_MODULE setting isn't part of the app the decorator definition belongs to (or is used on).</p> <p>I feel this should be easy, so there must be something subtle I am missing, maybe related to 'chaining' decorators?</p> <p>Any assistance much appreciated.</p> <p>Update: Here is my profile setting. </p> <pre><code>AUTH_PROFILE_MODULE = 'cta.account.models.user_profile.UserProfile' </code></pre> <p><em>Answer supplied below:</em> My profile model was incorrectly configured, it should have been</p> <pre><code>AUTH_PROFILE_MODULE = 'account.UserProfile' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload