--- a/web/lib/django/contrib/admindocs/views.py Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/contrib/admindocs/views.py Tue May 25 02:43:45 2010 +0200
@@ -187,14 +187,14 @@
try:
app_mod = models.get_app(app_label)
except ImproperlyConfigured:
- raise Http404, _("App %r not found") % app_label
+ raise Http404(_("App %r not found") % app_label)
model = None
for m in models.get_models(app_mod):
if m._meta.object_name.lower() == model_name:
model = m
break
if model is None:
- raise Http404, _("Model %(model_name)r not found in app %(app_label)r") % {'model_name': model_name, 'app_label': app_label}
+ raise Http404(_("Model %(model_name)r not found in app %(app_label)r") % {'model_name': model_name, 'app_label': app_label})
opts = model._meta
@@ -309,12 +309,17 @@
def load_all_installed_template_libraries():
# Load/register all template tag libraries from installed apps.
- for e in templatetags.__path__:
- libraries = [os.path.splitext(p)[0] for p in os.listdir(e) if p.endswith('.py') and p[0].isalpha()]
+ for module_name in template.get_templatetags_modules():
+ mod = import_module(module_name)
+ libraries = [
+ os.path.splitext(p)[0]
+ for p in os.listdir(os.path.dirname(mod.__file__))
+ if p.endswith('.py') and p[0].isalpha()
+ ]
for library_name in libraries:
try:
- lib = template.get_library("django.templatetags.%s" % library_name.split('.')[-1])
- except template.InvalidTemplateLibrary:
+ lib = template.get_library(library_name)
+ except template.InvalidTemplateLibrary, e:
pass
def get_return_data_type(func_name):
@@ -326,43 +331,12 @@
return 'Integer'
return ''
-# Maps Field objects to their human-readable data types, as strings.
-# Column-type strings can contain format strings; they'll be interpolated
-# against the values of Field.__dict__ before being output.
-# If a column type is set to None, it won't be included in the output.
-DATA_TYPE_MAPPING = {
- 'AutoField' : _('Integer'),
- 'BooleanField' : _('Boolean (Either True or False)'),
- 'CharField' : _('String (up to %(max_length)s)'),
- 'CommaSeparatedIntegerField': _('Comma-separated integers'),
- 'DateField' : _('Date (without time)'),
- 'DateTimeField' : _('Date (with time)'),
- 'DecimalField' : _('Decimal number'),
- 'EmailField' : _('E-mail address'),
- 'FileField' : _('File path'),
- 'FilePathField' : _('File path'),
- 'FloatField' : _('Floating point number'),
- 'ForeignKey' : _('Integer'),
- 'ImageField' : _('File path'),
- 'IntegerField' : _('Integer'),
- 'IPAddressField' : _('IP address'),
- 'ManyToManyField' : '',
- 'NullBooleanField' : _('Boolean (Either True, False or None)'),
- 'OneToOneField' : _('Relation to parent model'),
- 'PhoneNumberField' : _('Phone number'),
- 'PositiveIntegerField' : _('Integer'),
- 'PositiveSmallIntegerField' : _('Integer'),
- 'SlugField' : _('String (up to %(max_length)s)'),
- 'SmallIntegerField' : _('Integer'),
- 'TextField' : _('Text'),
- 'TimeField' : _('Time'),
- 'URLField' : _('URL'),
- 'USStateField' : _('U.S. state (two uppercase letters)'),
- 'XMLField' : _('XML text'),
-}
+def get_readable_field_data_type(field):
+ """Returns the description for a given field type, if it exists,
+ Fields' descriptions can contain format strings, which will be interpolated
+ against the values of field.__dict__ before being output."""
-def get_readable_field_data_type(field):
- return DATA_TYPE_MAPPING[field.get_internal_type()] % field.__dict__
+ return field.description % field.__dict__
def extract_views_from_urlpatterns(urlpatterns, base=''):
"""
@@ -384,7 +358,7 @@
continue
views.extend(extract_views_from_urlpatterns(patterns, base + p.regex.pattern))
else:
- raise TypeError, _("%s does not appear to be a urlpattern object") % p
+ raise TypeError(_("%s does not appear to be a urlpattern object") % p)
return views
named_group_matcher = re.compile(r'\(\?P(<\w+>).+?\)')