diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-21 21:53:18 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-21 21:53:18 +0000 |
| commit | 8e87587e89db8014300f0927799ea025fee53d15 (patch) | |
| tree | 0d107c5dc3b40076a92dc2432944d3c444c618f5 /django | |
| parent | ef454b8a14aa3ca1503c2230f44d71b9a5164670 (diff) | |
Fixed #3265 -- Made it a validation error to have field names with trailing
underscores. Allowing these would enable peopleto write ambiguous queryset
filters (plus makes parsing filters much harder).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6590 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/validation.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py index 9e004d3d25..c433b7fa96 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -35,6 +35,8 @@ def get_validation_errors(outfile, app=None): for f in opts.fields: if f.name == 'id' and not f.primary_key and opts.pk.name == 'id': e.add(opts, '"%s": You can\'t use "id" as a field name, because each model automatically gets an "id" field if none of the fields have primary_key=True. You need to either remove/rename your "id" field or add primary_key=True to a field.' % f.name) + if f.name.endswith('_'): + e.add(opts, '"%s": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name) if isinstance(f, models.CharField) and f.max_length in (None, 0): e.add(opts, '"%s": CharFields require a "max_length" attribute.' % f.name) if isinstance(f, models.DecimalField): |
