mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
magic-removal: Fixed a couple of typos
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1725 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
938f339c82
commit
10df9db788
@ -276,12 +276,12 @@ def get_sql_initial_data(app):
|
|||||||
from django.conf.settings import DATABASE_ENGINE
|
from django.conf.settings import DATABASE_ENGINE
|
||||||
from django.db.models import get_models
|
from django.db.models import get_models
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
app_models = get_models(app)
|
app_models = get_models(app)
|
||||||
app_label = app_models[0]._meta.app_label
|
app_label = app_models[0]._meta.app_label
|
||||||
output.append(_get_packages_insert(app_label))
|
output.append(_get_packages_insert(app_label))
|
||||||
app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))
|
app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))
|
||||||
|
|
||||||
for klass in app_models:
|
for klass in app_models:
|
||||||
opts = klass._meta
|
opts = klass._meta
|
||||||
|
|
||||||
@ -326,14 +326,14 @@ def get_sql_indexes(app):
|
|||||||
"Returns a list of the CREATE INDEX SQL statements for the given app."
|
"Returns a list of the CREATE INDEX SQL statements for the given app."
|
||||||
from django.db import backend, models
|
from django.db import backend, models
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for klass in models.get_models(app):
|
for klass in models.get_models(app):
|
||||||
for f in klass._meta.fields:
|
for f in klass._meta.fields:
|
||||||
if f.db_index:
|
if f.db_index:
|
||||||
unique = f.unique and "UNIQUE " or ""
|
unique = f.unique and "UNIQUE " or ""
|
||||||
output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \
|
output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \
|
||||||
(unique, klass._meta.db_table, f.column,
|
(unique, klass._meta.db_table, f.column,
|
||||||
baackend.quote_name(klass._meta.db_table), backend.quote_name(f.column)))
|
backend.quote_name(klass._meta.db_table), backend.quote_name(f.column)))
|
||||||
return output
|
return output
|
||||||
get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given model module name(s)."
|
get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given model module name(s)."
|
||||||
get_sql_indexes.args = APP_ARGS
|
get_sql_indexes.args = APP_ARGS
|
||||||
@ -473,7 +473,7 @@ def install(app):
|
|||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
app_name = app.__name__[app.__name__.rindex('.')+1:]
|
app_name = app.__name__[app.__name__.rindex('.')+1:]
|
||||||
app_label = app_name.split('.')[-1]
|
app_label = app_name.split('.')[-1]
|
||||||
|
|
||||||
# First, try validating the models.
|
# First, try validating the models.
|
||||||
s = StringIO()
|
s = StringIO()
|
||||||
num_errors = get_validation_errors(s)
|
num_errors = get_validation_errors(s)
|
||||||
@ -1076,4 +1076,3 @@ def execute_manager(settings_mod):
|
|||||||
|
|
||||||
# Run the django-admin.py command.
|
# Run the django-admin.py command.
|
||||||
execute_from_command_line(action_mapping)
|
execute_from_command_line(action_mapping)
|
||||||
|
|
||||||
|
@ -18,11 +18,9 @@ from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
|
|||||||
from django.db.models.exceptions import FieldDoesNotExist, BadKeywordArguments
|
from django.db.models.exceptions import FieldDoesNotExist, BadKeywordArguments
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
|
|
||||||
|
|
||||||
# Admin stages.
|
# Admin stages.
|
||||||
ADD, CHANGE, BOTH = 1, 2, 3
|
ADD, CHANGE, BOTH = 1, 2, 3
|
||||||
|
|
||||||
|
|
||||||
#def get_module(app_label, module_name):
|
#def get_module(app_label, module_name):
|
||||||
# return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', [''])
|
# return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', [''])
|
||||||
|
|
||||||
@ -34,20 +32,18 @@ def get_models(app):
|
|||||||
def get_models_helper(mod, seen_models):
|
def get_models_helper(mod, seen_models):
|
||||||
if hasattr(mod, '_MODELS'):
|
if hasattr(mod, '_MODELS'):
|
||||||
seen_models.extend(mod._MODELS)
|
seen_models.extend(mod._MODELS)
|
||||||
if hasattr(mod, '__all__'):
|
if hasattr(mod, '__all__'):
|
||||||
for name in mod.__all__:
|
for name in mod.__all__:
|
||||||
sub_mod = __import__("%s.%s" % (mod.__name__, name), '','',[''])
|
sub_mod = __import__("%s.%s" % (mod.__name__, name), '','',[''])
|
||||||
get_models_helper(sub_mod, seen_models)
|
get_models_helper(sub_mod, seen_models)
|
||||||
|
|
||||||
def get_app(app_label):
|
def get_app(app_label):
|
||||||
|
|
||||||
for app_name in settings.INSTALLED_APPS:
|
for app_name in settings.INSTALLED_APPS:
|
||||||
comps = app_name.split('.')
|
comps = app_name.split('.')
|
||||||
if app_label == comps[-1]:
|
if app_label == comps[-1]:
|
||||||
app_models = __import__('%s.models' % app_name , '','',[''])
|
app_models = __import__('%s.models' % app_name , '','',[''])
|
||||||
return app_models
|
return app_models
|
||||||
|
raise ImproperlyConfigured, "App with label %s could not be found" % app_label
|
||||||
raise ImproperlyConfigured, "App with label %s could not be found" % app_labelpostgres
|
|
||||||
|
|
||||||
class LazyDate:
|
class LazyDate:
|
||||||
"""
|
"""
|
||||||
@ -69,10 +65,3 @@ class LazyDate:
|
|||||||
|
|
||||||
def __get_value__(self):
|
def __get_value__(self):
|
||||||
return datetime.datetime.now() + self.delta
|
return datetime.datetime.now() + self.delta
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user