From 631ef6b2729f79c75f35cd32caa504dda7c32e9e Mon Sep 17 00:00:00 2001 From: François Freitag Date: Sat, 17 Sep 2016 06:29:14 -0700 Subject: Made FieldError/FieldDoesNotExist messages uniform across Python versions. Removed possible u'' prefixes on Python 2. --- django/db/models/options.py | 6 +++--- django/db/models/sql/query.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'django') diff --git a/django/db/models/options.py b/django/db/models/options.py index 51022ab902..0cf1726315 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -223,7 +223,7 @@ class Options(object): if f.name == query or f.attname == query ) except StopIteration: - raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, query)) + raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, query)) self.ordering = ('_order',) if not any(isinstance(field, OrderWrt) for field in model._meta.local_fields): @@ -605,7 +605,7 @@ class Options(object): # unavailable, therefore we throw a FieldDoesNotExist exception. if not self.apps.models_ready: raise FieldDoesNotExist( - "%s has no field named %r. The app cache isn't ready yet, " + "%s has no field named '%s'. The app cache isn't ready yet, " "so if this is an auto-created related field, it won't " "be available yet." % (self.object_name, field_name) ) @@ -615,7 +615,7 @@ class Options(object): # field map. return self.fields_map[field_name] except KeyError: - raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name)) + raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name)) def get_base_chain(self, model): """ diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 9c46ee4ca1..e6516194dd 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1339,7 +1339,7 @@ class Query(object): if pos == -1 or fail_on_missing: field_names = list(get_field_names_from_opts(opts)) available = sorted(field_names + list(self.annotation_select)) - raise FieldError("Cannot resolve keyword %r into field. " + raise FieldError("Cannot resolve keyword '%s' into field. " "Choices are: %s" % (name, ", ".join(available))) break # Check if we need any joins for concrete inheritance cases (the -- cgit v1.3