diff --git a/django/core/db/backends/ado_mssql.py b/django/core/db/backends/ado_mssql.py index cc2f861ea7..709d35a583 100644 --- a/django/core/db/backends/ado_mssql.py +++ b/django/core/db/backends/ado_mssql.py @@ -138,7 +138,6 @@ DATA_TYPES = { 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'smalldatetime', 'DateTimeField': 'smalldatetime', - 'EmailField': 'varchar(75)', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', diff --git a/django/core/db/backends/mysql.py b/django/core/db/backends/mysql.py index dd94948b96..27d166f8d1 100644 --- a/django/core/db/backends/mysql.py +++ b/django/core/db/backends/mysql.py @@ -154,7 +154,6 @@ DATA_TYPES = { 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'datetime', - 'EmailField': 'varchar(75)', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', diff --git a/django/core/db/backends/postgresql.py b/django/core/db/backends/postgresql.py index b1b2d9cb52..03864a5707 100644 --- a/django/core/db/backends/postgresql.py +++ b/django/core/db/backends/postgresql.py @@ -159,7 +159,6 @@ DATA_TYPES = { 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'timestamp with time zone', - 'EmailField': 'varchar(75)', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', diff --git a/django/core/db/backends/sqlite3.py b/django/core/db/backends/sqlite3.py index 60ffd37620..6fa49131ee 100644 --- a/django/core/db/backends/sqlite3.py +++ b/django/core/db/backends/sqlite3.py @@ -157,7 +157,6 @@ DATA_TYPES = { 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'datetime', - 'EmailField': 'varchar(75)', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', diff --git a/django/core/formfields.py b/django/core/formfields.py index 8c8915ba6f..bca58253a9 100644 --- a/django/core/formfields.py +++ b/django/core/formfields.py @@ -778,9 +778,9 @@ class TimeField(TextField): class EmailField(TextField): "A convenience FormField for validating e-mail addresses" - def __init__(self, field_name, length=50, is_required=False, validator_list=[]): + def __init__(self, field_name, length=50, maxlength=75, is_required=False, validator_list=[]): validator_list = [self.isValidEmail] + validator_list - TextField.__init__(self, field_name, length, maxlength=75, + TextField.__init__(self, field_name, length, maxlength=maxlength, is_required=is_required, validator_list=validator_list) def isValidEmail(self, field_data, all_data): diff --git a/django/core/management.py b/django/core/management.py index 5553d4345b..baccae1953 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -604,6 +604,11 @@ def get_validation_errors(outfile): for f in opts.fields: if isinstance(f, meta.CharField) and f.maxlength in (None, 0): e.add(opts, '"%s" field: CharFields require a "maxlength" attribute.' % f.name) + if isinstance(f, meta.FloatField): + if f.decimal_places is None: + e.add(opts, '"%s" field: FloatFields require a "decimal_places" attribute.' % f.name) + if f.max_digits is None: + e.add(opts, '"%s" field: FloatFields require a "max_digits" attribute.' % f.name) if isinstance(f, meta.FileField) and not f.upload_to: e.add(opts, '"%s" field: FileFields require an "upload_to" attribute.' % f.name) if isinstance(f, meta.ImageField): diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 47ea0720e1..6cf7bd0d43 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -890,12 +890,13 @@ def method_init(opts, self, *args, **kwargs): except KeyError: val = f.get_default() else: + # Object instance was passed in. # Special case: You can pass in "None" for related objects if it's allowed. if rel_obj is None and f.null: val = None else: try: - val = getattr(rel_obj, f.rel.field_name) + val = getattr(rel_obj, f.rel.get_related_field().attname) except AttributeError: raise TypeError, "Invalid value: %r should be a %s instance, not a %s" % (f.name, f.rel.to, type(rel_obj)) setattr(self, f.attname, val) @@ -1028,7 +1029,12 @@ def method_get_many_to_one(field_with_rel, self): mod = field_with_rel.rel.to.get_model_module() if val is None: raise getattr(mod, '%sDoesNotExist' % field_with_rel.rel.to.object_name) - retrieved_obj = mod.get_object(**{'%s__exact' % field_with_rel.rel.field_name: val}) + other_field = field_with_rel.rel.get_related_field() + if other_field.rel: + params = {'%s__%s__exact' % (field_with_rel.rel.field_name, other_field.rel.field_name): val} + else: + params = {'%s__exact'% field_with_rel.rel.field_name: val} + retrieved_obj = mod.get_object(**params) setattr(self, cache_var, retrieved_obj) return getattr(self, cache_var) @@ -1094,7 +1100,7 @@ def method_get_related(method_name, rel_mod, rel_field, self, **kwargs): if self._meta.has_related_links and rel_mod.Klass._meta.module_name == 'relatedlinks': kwargs['object_id__exact'] = getattr(self, rel_field.rel.field_name) else: - kwargs['%s__%s__exact' % (rel_field.name, rel_field.rel.to.pk.name)] = getattr(self, rel_field.rel.field_name) + kwargs['%s__%s__exact' % (rel_field.name, rel_field.rel.to.pk.name)] = getattr(self, rel_field.rel.get_related_field().attname) kwargs.update(rel_field.rel.lookup_overrides) return getattr(rel_mod, method_name)(**kwargs) diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index e4a360f83e..17a9a7e4b0 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -460,6 +460,13 @@ class DateTimeField(DateField): time_field: (val is not None and val.strftime("%H:%M:%S") or '')} class EmailField(Field): + def __init__(self, *args, **kwargs): + kwargs['maxlength'] = 75 + Field.__init__(self, *args, **kwargs) + + def get_internal_type(self): + return "CharField" + def get_manipulator_field_objs(self): return [formfields.EmailField] diff --git a/docs/faq.txt b/docs/faq.txt index 58caf32b30..cd8912a706 100644 --- a/docs/faq.txt +++ b/docs/faq.txt @@ -240,6 +240,15 @@ See our `Django-friendly Web hosts`_ page. .. _`Django-friendly Web hosts`: http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts +Should I use the official version or development version? +--------------------------------------------------------- + +The Django developers improve Django every day and are pretty good about not +checking in broken code. We use the development code (from the Subversion +repository) directly on our servers, so we consider it stable. With that in +mind, we recommend that you use the latest development code, because it +generally contains more features and fewer bugs than the "official" releases. + Using Django ============ diff --git a/docs/settings.txt b/docs/settings.txt index 7fe9a56237..eed9d03d39 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -591,8 +591,11 @@ TIME_ZONE Default: ``'America/Chicago'`` -A string representing the time zone for this installation. -`See available choices`_. +A string representing the time zone for this installation. `See available choices`_. + +Note that this is the time zone to which Django will convert all dates/times -- +not necessarily the timezone of the server. For example, one server may serve +multiple Django-powered sites, each with a separate time-zone setting. USE_ETAGS --------- diff --git a/tests/testapp/models/many_to_one.py b/tests/testapp/models/many_to_one.py index 91dae95614..37828b6d82 100644 --- a/tests/testapp/models/many_to_one.py +++ b/tests/testapp/models/many_to_one.py @@ -9,6 +9,7 @@ from django.core import meta class Reporter(meta.Model): first_name = meta.CharField(maxlength=30) last_name = meta.CharField(maxlength=30) + email = meta.EmailField() def __repr__(self): return "%s %s" % (self.first_name, self.last_name) @@ -23,7 +24,7 @@ class Article(meta.Model): API_TESTS = """ # Create a Reporter. ->>> r = reporters.Reporter(first_name='John', last_name='Smith') +>>> r = reporters.Reporter(first_name='John', last_name='Smith', email='john@example.com') >>> r.save() # Create an Article. diff --git a/tests/testapp/models/one_to_one.py b/tests/testapp/models/one_to_one.py index 7c1d669566..5b384aa82b 100644 --- a/tests/testapp/models/one_to_one.py +++ b/tests/testapp/models/one_to_one.py @@ -28,7 +28,7 @@ class Waiter(meta.Model): name = meta.CharField(maxlength=50) def __repr__(self): - return "%s the waiter at %s" % (self.name, self.get_restaurant()) + return "%s the waiter at %r" % (self.name, self.get_restaurant()) API_TESTS = """ # Create a couple of Places.