Opened 19 years ago

Closed 19 years ago

#861 closed defect (fixed)

Warn on single-letter field names in unique_together

Reported by: garthk Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If a user puts a single pair of field names in unique_together, they'll get something looking like this traceback when they try to install the application:

Traceback (most recent call last):
  File "C:\dev\django-svn\django\core\management.py", line 389, in install
    sql_list = get_sql_all(mod)
  File "C:\dev\django-svn\django\core\management.py", line 261, in get_sql_all
    return get_sql_create(mod) + get_sql_initial_data(mod)
  File "C:\dev\django-svn\django\core\management.py", line 88, in get_sql_create
    table_output.append('UNIQUE (%s)' % \
  File "C:\dev\django-svn\django\core\meta\__init__.py", line 393, in get_field
    raise FieldDoesNotExist, "name=%s" % name
django.core.meta.FieldDoesNotExist: name=f

The user might waste a lot of time figuring out that the reason for this is that they specified ('field1', 'field2') or (('field1', 'field2')) rather than (('field1', 'field2'),) or [('field1', 'field2')].

Attachments (1)

861.diff (1.0 KB ) - added by garthk 19 years ago.
Patch with descriptive error

Download all attachments as: .zip

Change History (2)

by garthk, 19 years ago

Attachment: 861.diff added

Patch with descriptive error

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [1323]) Fixed #861 -- Model validator now validates unique_together

Note: See TracTickets for help on using tickets.
Back to Top