From f0c493f02f78370916d7f70b3f1b705921035b4e Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 17 Feb 2006 19:42:11 +0000 Subject: [PATCH] magic-removal: Merged to [2328] git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2329 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/__init__.py | 1 + django/contrib/admin/views/doc.py | 2 +- django/contrib/admin/views/main.py | 2 +- django/core/management.py | 22 +++++++++++++++------- django/db/backends/ado_mssql/creation.py | 2 +- django/db/backends/mysql/creation.py | 2 +- django/db/backends/postgresql/creation.py | 2 +- django/db/backends/sqlite3/creation.py | 2 +- docs/model-api.txt | 6 +++++- 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2296b3fc4f..ea0085b136 100644 --- a/AUTHORS +++ b/AUTHORS @@ -88,6 +88,7 @@ answer newbie questions, and generally made Django that much better: Luke Plant plisk Daniel Poelzleithner + J. Rademaker Brian Ray Oliver Rutherfurd David Schein diff --git a/django/__init__.py b/django/__init__.py index e69de29bb2..593e2f46e4 100644 --- a/django/__init__.py +++ b/django/__init__.py @@ -0,0 +1 @@ +VERSION = (0, 9, 1, 'SVN') diff --git a/django/contrib/admin/views/doc.py b/django/contrib/admin/views/doc.py index acc478d31b..ddda5b270d 100644 --- a/django/contrib/admin/views/doc.py +++ b/django/contrib/admin/views/doc.py @@ -266,7 +266,7 @@ DATA_TYPE_MAPPING = { 'PhoneNumberField' : _('Phone number'), 'PositiveIntegerField' : _('Integer'), 'PositiveSmallIntegerField' : _('Integer'), - 'SlugField' : _('String (up to 50)'), + 'SlugField' : _('String (up to %(maxlength)s)'), 'SmallIntegerField' : _('Integer'), 'TextField' : _('Text'), 'TimeField' : _('Time'), diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index e5abc2a2a0..86754b91c7 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -403,7 +403,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current if related.opts.admin and has_related_objs: p = '%s.%s' % (related.opts.app_label, related.opts.get_delete_permission()) if not user.has_perm(p): - perms_needed.add(rel_opts.verbose_name) + perms_needed.add(rel_opts_name) for related in opts.get_all_related_many_to_many_objects(): if related.opts in opts_seen: continue diff --git a/django/core/management.py b/django/core/management.py index d7349f265a..079674e6f5 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -64,6 +64,14 @@ def _is_valid_dir_name(s): # field as the field to which it points. get_rel_data_type = lambda f: (f.get_internal_type() in ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' or f.get_internal_type() +def get_version(): + "Returns the version as a human-format string." + from django import VERSION + v = '.'.join([str(i) for i in VERSION[:-1]]) + if VERSION[3]: + v += ' (%s)' % VERSION[3] + return v + def get_sql_create(app): "Returns a list of the CREATE TABLE SQL statements for the given app." from django.db import backend, get_creation_module, models @@ -821,8 +829,8 @@ class ModelErrorCollection: def get_validation_errors(outfile, app=None): """ - Validates all models that are part of the specified app. If no app name is provided, - validates all models of all installed apps. Writes errors, if any, to outfile. + Validates all models that are part of the specified app. If no app name is provided, + validates all models of all installed apps. Writes errors, if any, to outfile. Returns number of errors. """ from django.db import models @@ -870,7 +878,7 @@ def get_validation_errors(outfile, app=None): rel_opts = f.rel.to._meta if f.rel.to not in models.get_models(): e.add(opts, "'%s' relates to uninstalled model %s" % (f.name, rel_opts.object_name)) - + rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() for r in rel_opts.fields: if r.name == rel_name: @@ -879,12 +887,12 @@ def get_validation_errors(outfile, app=None): if r.name == rel_name: e.add(opts, "'%s' accessor name '%s.%s' clashes with a m2m field" % (f.name, rel_opts.object_name, r.name)) for r in rel_opts.get_all_related_many_to_many_objects(): - if r.get_accessor_name() == rel_name: + if r.get_accessor_name() == rel_name: e.add(opts, "'%s' accessor name '%s.%s' clashes with a related m2m field" % (f.name, rel_opts.object_name, r.get_accessor_name())) for r in rel_opts.get_all_related_objects(): if r.get_accessor_name() == rel_name and r.field is not f: e.add(opts, "'%s' accessor name '%s.%s' clashes with a related field" % (f.name, rel_opts.object_name, r.get_accessor_name())) - + for i, f in enumerate(opts.many_to_many): # Check to see if the related m2m field will clash with any # existing fields, m2m fields, m2m related objects or related objects @@ -900,7 +908,7 @@ def get_validation_errors(outfile, app=None): if r.name == rel_name: e.add(opts, "'%s' m2m accessor name '%s.%s' clashes with a m2m field" % (f.name, rel_opts.object_name, r.name)) for r in rel_opts.get_all_related_many_to_many_objects(): - if r.get_accessor_name() == rel_name and r.field is not f: + if r.get_accessor_name() == rel_name and r.field is not f: e.add(opts, "'%s' m2m accessor name '%s.%s' clashes with a related m2m field" % (f.name, rel_opts.object_name, r.get_accessor_name())) for r in rel_opts.get_all_related_objects(): if r.get_accessor_name() == rel_name: @@ -1119,7 +1127,7 @@ def print_error(msg, cmd): def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING): # Parse the command-line arguments. optparse handles the dirty work. - parser = DjangoOptionParser(get_usage(action_mapping)) + parser = DjangoOptionParser(usage=get_usage(action_mapping), version=get_version()) parser.add_option('--settings', help='Python path to settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.') parser.add_option('--pythonpath', diff --git a/django/db/backends/ado_mssql/creation.py b/django/db/backends/ado_mssql/creation.py index 493512f1fb..4d85d27ea5 100644 --- a/django/db/backends/ado_mssql/creation.py +++ b/django/db/backends/ado_mssql/creation.py @@ -17,7 +17,7 @@ DATA_TYPES = { 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'int CONSTRAINT [CK_int_pos_%(column)s] CHECK ([%(column)s] > 0)', 'PositiveSmallIntegerField': 'smallint CONSTRAINT [CK_smallint_pos_%(column)s] CHECK ([%(column)s] > 0)', - 'SlugField': 'varchar(50)', + 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', diff --git a/django/db/backends/mysql/creation.py b/django/db/backends/mysql/creation.py index 4a29c18b13..f03758e3b2 100644 --- a/django/db/backends/mysql/creation.py +++ b/django/db/backends/mysql/creation.py @@ -21,7 +21,7 @@ DATA_TYPES = { 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer UNSIGNED', 'PositiveSmallIntegerField': 'smallint UNSIGNED', - 'SlugField': 'varchar(50)', + 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'longtext', 'TimeField': 'time', diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index accc383330..65a804ec40 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -21,7 +21,7 @@ DATA_TYPES = { 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)', 'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)', - 'SlugField': 'varchar(50)', + 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py index 945ae0c477..e845179e64 100644 --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -20,7 +20,7 @@ DATA_TYPES = { 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer unsigned', 'PositiveSmallIntegerField': 'smallint unsigned', - 'SlugField': 'varchar(50)', + 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', diff --git a/docs/model-api.txt b/docs/model-api.txt index 746f63f44f..02c39bb3ec 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -410,7 +410,11 @@ Here are all available field types: containing only letters, numbers, underscores or hyphens. They're generally used in URLs. - Implies ``maxlength=50`` and ``db_index=True``. + In the Django development version, you can specify ``maxlength``. If + ``maxlength`` is not specified, Django will use a default length of 50. In + previous Django versions, there's no way to override the length of 50. + + Implies ``db_index=True``. Accepts an extra option, ``prepopulate_from``, which is a list of fields from which to auto-populate the slug, via JavaScript, in the object's admin