summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-11-17 15:36:26 +0000
committerJannis Leidel <jannis@leidel.info>2010-11-17 15:36:26 +0000
commit33d8fcde8a317184a627492f008a4eab9333ed88 (patch)
tree7c877854327c83aefdfaf00e727d26bd766e519e /django/forms
parent9b45f6cd5444423693715cc2a04d91a0de75060b (diff)
Fixed #14693, #14709 -- Backwards incompatible change to rectify the confusion around the STATICFILES_URL and STATICFILES_ROOT settings.
* Two new global settings that will be used by -- **but are not limited to** -- the staticfiles app: STATIC_ROOT and STATIC_URL. * Moving the 'django.contrib.staticfiles.templatetags.staticfiles' template tag to the core ('django.templatetags.static') and renaming it to 'get_static_prefix'. * Moving the context processor 'django.contrib.staticfiles.context_processors.staticfiles' to the core ('django.core.context_processors.static') and renaming it to 'static'. * Paths in media definitions will use STATIC_URL as the prefix if the value is not None, and falls back to the previously used MEDIA_URL. Thanks again to the community for constructive criticism and Carl and Russ for sanity-inducing discussions on IRC. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/widgets.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index cb12586d6c..8eb5fef3e7 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -1,9 +1,13 @@
"""
HTML Widget classes
"""
+import datetime
+from itertools import chain
+import time
+from urlparse import urljoin
+from util import flatatt
import django.utils.copycompat as copy
-from itertools import chain
from django.conf import settings
from django.utils.datastructures import MultiValueDict, MergeDict
from django.utils.html import escape, conditional_escape
@@ -11,10 +15,6 @@ from django.utils.translation import ugettext, ugettext_lazy
from django.utils.encoding import StrAndUnicode, force_unicode
from django.utils.safestring import mark_safe
from django.utils import datetime_safe, formats
-import time
-import datetime
-from util import flatatt
-from urlparse import urljoin
__all__ = (
'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'PasswordInput',
@@ -63,10 +63,16 @@ class Media(StrAndUnicode):
for path in self._css[medium]]
for medium in media])
- def absolute_path(self, path):
+ def absolute_path(self, path, prefix=None):
if path.startswith(u'http://') or path.startswith(u'https://') or path.startswith(u'/'):
return path
- return urljoin(settings.MEDIA_URL,path)
+ if prefix is None:
+ if settings.STATIC_URL is None:
+ # backwards compatibility
+ prefix = settings.MEDIA_URL
+ else:
+ prefix = settings.STATIC_URL
+ return urljoin(prefix, path)
def __getitem__(self, name):
"Returns a Media object that only contains media of the given type"