Django

Code

Ticket #861 (closed: fixed)

Opened 3 years ago

Last modified 3 years ago

Warn on single-letter field names in unique_together

Reported by: garthk Assigned to: adrian
Milestone: Component: Admin interface
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

861.diff (1.0 kB) - added by garthk on 11/20/05 19:37:00.
Patch with descriptive error

Change History

11/20/05 19:37:00 changed by garthk

  • attachment 861.diff added.

Patch with descriptive error

11/20/05 19:45:16 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #861 (Warn on single-letter field names in unique_together)




Change Properties
Action