diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2011-08-23 23:43:29 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2011-08-23 23:43:29 +0000 |
| commit | 75ddbf77a62b804740e887d940ded2f8c0bc1087 (patch) | |
| tree | 8924ab796e4c6788d5533ab052a9284a988ae79b /django | |
| parent | 8b87a94357c1e52c9d5aed8c684e1a4f1dcc1c89 (diff) | |
Teach "django-admin.py validate" to forbid nullable primary keys.
Fixes #15884, with thanks to JustinTArthur and Julie Pichon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16678 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 55665804c4..c13b19df97 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -39,6 +39,8 @@ def get_validation_errors(outfile, app=None): 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 f.primary_key and f.null: + e.add(opts, '"%s": Primary key fields cannot have null=True.' % f.name) if isinstance(f, models.CharField): try: max_length = int(f.max_length) |
