Fixed bug in dynamically-generated docs -- ForeignKeys were throwing an exception

git-svn-id: http://code.djangoproject.com/svn/django/trunk@182 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-18 20:35:51 +00:00
parent cf4c164e9f
commit 12c04fbf29
1 changed files with 5 additions and 1 deletions

View File

@ -275,6 +275,7 @@ DATA_TYPE_MAPPING = {
'EmailField' : 'E-mail address',
'FileField' : 'File path',
'FloatField' : 'Decimal number',
'ForeignKey' : 'Integer',
'ImageField' : 'File path',
'IntegerField' : 'Integer',
'IPAddressField' : 'IP address',
@ -293,6 +294,9 @@ DATA_TYPE_MAPPING = {
}
def get_readable_field_data_type(field):
# ForeignKey is a special case. Use the field type of the relation.
if field.__class__.__name__ == 'ForeignKey':
field = field.rel.get_related_field()
return DATA_TYPE_MAPPING[field.__class__.__name__] % field.__dict__
def extract_views_from_urlpatterns(urlpatterns, base=''):
@ -325,4 +329,4 @@ def simplify_regex(pattern):
pattern = pattern.replace('^', '').replace('$', '').replace('?', '').replace('//', '/')
if not pattern.startswith('/'):
pattern = '/' + pattern
return pattern
return pattern