From 918497218c58227f5032873ff97261627b2ceab2 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 15 Sep 2012 20:18:19 +0800 Subject: [PATCH] Deprecate AUTH_PROFILE_MODULE and get_profile(). --- django/contrib/auth/models.py | 4 +++- docs/internals/deprecation.txt | 3 +++ docs/ref/settings.txt | 26 ++++++++++++++++---------- docs/releases/1.5.txt | 13 +++++++++++++ docs/topics/auth.txt | 8 +++++++- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 972aab239b..b9ba0193ba 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals import re -import urllib +import warnings from django.core.exceptions import ImproperlyConfigured from django.core.mail import send_mail @@ -405,6 +405,8 @@ class User(AbstractBaseUser): Returns site-specific profile for this user. Raises SiteProfileNotAvailable if this site does not allow profiles. """ + warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.", + PendingDeprecationWarning) if not hasattr(self, '_profile_cache'): from django.conf import settings if not getattr(settings, 'AUTH_PROFILE_MODULE', False): diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 4add751912..45febb7c6b 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -286,6 +286,9 @@ these changes. * The ``mimetype`` argument to :class:`~django.http.HttpResponse` ``__init__`` will be removed (``content_type`` should be used instead). +* The ``AUTH_PROFILE_MODULE`` setting, and the ``get_profile()`` method on + the User model, will be removed. + 2.0 --- diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 8ab3f90a63..65844b2eb2 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -110,16 +110,6 @@ A tuple of authentication backend classes (as strings) to use when attempting to authenticate a user. See the :doc:`authentication backends documentation ` for details. -.. setting:: AUTH_PROFILE_MODULE - -AUTH_PROFILE_MODULE -------------------- - -Default: Not defined - -The site-specific user profile model used by this site. See -:ref:`auth-profiles`. - .. setting:: AUTH_USER_MODEL AUTH_USER_MODEL @@ -2243,6 +2233,22 @@ ADMIN_MEDIA_PREFIX integration. See the :doc:`Django 1.4 release notes` for more information. +.. setting:: AUTH_PROFILE_MODULE + +AUTH_PROFILE_MODULE +------------------- + +.. deprecated:: 1.5 + With the introduction of :ref:`custom User models `, + the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile + model is no longer supported. See the + :doc:`Django 1.5 release notes` for more information. + +Default: Not defined + +The site-specific user profile model used by this site. See +:ref:`auth-profiles`. + .. setting:: IGNORABLE_404_ENDS IGNORABLE_404_ENDS diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index 921742163f..a72d3dba99 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -389,3 +389,16 @@ The markup contrib module has been deprecated and will follow an accelerated deprecation schedule. Direct use of python markup libraries or 3rd party tag libraries is preferred to Django maintaining this functionality in the framework. + +:setting:`AUTH_PROFILE_MODULE` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +With the introduction of :ref:`custom User models `, there is +no longer any need for a built-in mechanism to store user profile data. + +You can still define user profiles models that have a one-to-one relation with +the User model - in fact, for many applications needing to associate data with +a User account, this will be an appropriate design pattern to follow. However, +the :setting:`AUTH_PROFILE_MODULE` setting, and the +:meth:`~django.contrib.auth.models.User.get_profile()` method for accessing +the user profile model, should not be used any longer. diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt index c141d9eb15..553ec7b516 100644 --- a/docs/topics/auth.txt +++ b/docs/topics/auth.txt @@ -586,6 +586,12 @@ correct path and environment for you. Storing additional information about users ------------------------------------------ +.. deprecated:: 1.5 + With the introduction of :ref:`custom User models `, + the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile + model is no longer supported. See the + :doc:`Django 1.5 release notes` for more information. + If you'd like to store additional information related to your users, Django provides a method to specify a site-specific related model -- termed a "user profile" -- for this purpose. @@ -952,7 +958,7 @@ The login_required decorator (r'^accounts/login/$', 'django.contrib.auth.views.login'), .. versionchanged:: 1.5 - + As of version 1.5 :setting:`settings.LOGIN_URL ` now also accepts view function names and :ref:`named URL patterns `. This allows you to freely remap your login view within your URLconf