188
188
app_mod = models.get_app(app_label)
189
189
except ImproperlyConfigured:
190
raise Http404, _("App %r not found") % app_label
190
raise Http404(_("App %r not found") % app_label)
192
192
for m in models.get_models(app_mod):
193
193
if m._meta.object_name.lower() == model_name:
196
196
if model is None:
197
raise Http404, _("Model %(model_name)r not found in app %(app_label)r") % {'model_name': model_name, 'app_label': app_label}
197
raise Http404(_("Model %(model_name)r not found in app %(app_label)r") % {'model_name': model_name, 'app_label': app_label})
199
199
opts = model._meta
310
310
def load_all_installed_template_libraries():
311
311
# Load/register all template tag libraries from installed apps.
312
for e in templatetags.__path__:
313
libraries = [os.path.splitext(p)[0] for p in os.listdir(e) if p.endswith('.py') and p[0].isalpha()]
312
for module_name in template.get_templatetags_modules():
313
mod = import_module(module_name)
315
os.path.splitext(p)[0]
316
for p in os.listdir(os.path.dirname(mod.__file__))
317
if p.endswith('.py') and p[0].isalpha()
314
319
for library_name in libraries:
316
lib = template.get_library("django.templatetags.%s" % library_name.split('.')[-1])
317
except template.InvalidTemplateLibrary:
321
lib = template.get_library(library_name)
322
except template.InvalidTemplateLibrary, e:
320
325
def get_return_data_type(func_name):
329
# Maps Field objects to their human-readable data types, as strings.
330
# Column-type strings can contain format strings; they'll be interpolated
331
# against the values of Field.__dict__ before being output.
332
# If a column type is set to None, it won't be included in the output.
333
DATA_TYPE_MAPPING = {
334
'AutoField' : _('Integer'),
335
'BooleanField' : _('Boolean (Either True or False)'),
336
'CharField' : _('String (up to %(max_length)s)'),
337
'CommaSeparatedIntegerField': _('Comma-separated integers'),
338
'DateField' : _('Date (without time)'),
339
'DateTimeField' : _('Date (with time)'),
340
'DecimalField' : _('Decimal number'),
341
'EmailField' : _('E-mail address'),
342
'FileField' : _('File path'),
343
'FilePathField' : _('File path'),
344
'FloatField' : _('Floating point number'),
345
'ForeignKey' : _('Integer'),
346
'ImageField' : _('File path'),
347
'IntegerField' : _('Integer'),
348
'IPAddressField' : _('IP address'),
349
'ManyToManyField' : '',
350
'NullBooleanField' : _('Boolean (Either True, False or None)'),
351
'OneToOneField' : _('Relation to parent model'),
352
'PhoneNumberField' : _('Phone number'),
353
'PositiveIntegerField' : _('Integer'),
354
'PositiveSmallIntegerField' : _('Integer'),
355
'SlugField' : _('String (up to %(max_length)s)'),
356
'SmallIntegerField' : _('Integer'),
357
'TextField' : _('Text'),
358
'TimeField' : _('Time'),
359
'URLField' : _('URL'),
360
'USStateField' : _('U.S. state (two uppercase letters)'),
361
'XMLField' : _('XML text'),
364
334
def get_readable_field_data_type(field):
365
return DATA_TYPE_MAPPING[field.get_internal_type()] % field.__dict__
335
"""Returns the description for a given field type, if it exists,
336
Fields' descriptions can contain format strings, which will be interpolated
337
against the values of field.__dict__ before being output."""
339
return field.description % field.__dict__
367
341
def extract_views_from_urlpatterns(urlpatterns, base=''):