Ticket #12404: 12404_patch.diff
File 12404_patch.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/core/management/validation.py
37 37 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) 38 38 if f.name.endswith('_'): 39 39 e.add(opts, '"%s": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name) 40 if isinstance(f, models.CharField) and f.max_length in (None, 0): 41 e.add(opts, '"%s": CharFields require a "max_length" attribute.' % f.name) 40 if isinstance(f, models.CharField): 41 try: 42 max_length = int(f.max_length) 43 if max_length <= 0: 44 e.add(opts, '"%s": CharFields require a "max_length attribute greater than zero."' % f.name) 45 except ValueError: 46 e.add(opts, '"%s": CharFields require a "max_length" attribute of type int.' % f.name) 42 47 if isinstance(f, models.DecimalField): 43 48 if f.decimal_places is None: 44 49 e.add(opts, '"%s": DecimalFields require a "decimal_places" attribute.' % f.name)