Kaydet (Commit) 12c04fbf authored tarafından Adrian Holovaty's avatar Adrian Holovaty

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
üst cf4c164e
......@@ -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
\ No newline at end of file
return pattern
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment