diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/options.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py index 502cbc4a65..788d1c80de 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -52,9 +52,19 @@ class Options(object): del meta_attrs['__doc__'] for attr_name in DEFAULT_NAMES: setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) + + # unique_together can be either a tuple of tuples, or a single + # tuple of two strings. Normalize it to a tuple of tuples, so that + # calling code can uniformly expect that. + ut = meta_attrs.pop('unique_together', getattr(self, 'unique_together')) + if ut and not isinstance(ut[0], (tuple, list)): + ut = (ut,) + setattr(self, 'unique_together', ut) + # verbose_name_plural is a special case because it uses a 's' # by default. setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's'))) + # Any leftover attributes must be invalid. if meta_attrs != {}: raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) |
