Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed django-admin so that it doesn't load django.core.db or django…

….core.meta unless it needs to. As a result, 'django-admin startproject' works even if the database parameters are set incorrectly

git-svn-id: http://code.djangoproject.com/svn/django/trunk@101 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2b40dee38dee47a58ce2da61002bf9e42bf20761 1 parent 451cdae
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 django/bin/django-admin.py
View
10 django/bin/django-admin.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-from django.core import db, meta
import django
import os, re, sys
@@ -45,6 +44,7 @@ def _is_valid_dir_name(s):
def get_sql_create(mod):
"Returns a list of the CREATE TABLE SQL statements for the given module."
+ from django.core import db, meta
final_output = []
for klass in mod._MODELS:
opts = klass._meta
@@ -104,6 +104,7 @@ def get_sql_create(mod):
def get_sql_delete(mod):
"Returns a list of the DROP TABLE SQL statements for the given module."
+ from django.core import db
try:
cursor = db.db.cursor()
except:
@@ -166,6 +167,7 @@ def get_sql_initial_data(mod):
def get_sql_sequence_reset(mod):
"Returns a list of the SQL statements to reset PostgreSQL sequences for the given module."
+ from django.core import meta
output = []
for klass in mod._MODELS:
for f in klass._meta.fields:
@@ -196,6 +198,7 @@ def get_sql_all(mod):
def database_check(mod):
"Checks that everything is properly installed in the database for the given module."
+ from django.core import db
cursor = db.db.cursor()
app_label = mod._MODELS[0]._meta.app_label
@@ -247,6 +250,7 @@ def database_check(mod):
def get_admin_index(mod):
"Returns admin-index template snippet (in list form) for the given module."
+ from django.core import meta
output = []
app_label = mod._MODELS[0]._meta.app_label
output.append('{%% if perms.%s %%}' % app_label)
@@ -268,6 +272,7 @@ def get_admin_index(mod):
def init():
"Initializes the database with auth and core."
+ from django.core import db, meta
auth = meta.get_app('auth')
core = meta.get_app('core')
try:
@@ -284,6 +289,7 @@ def init():
def install(mod):
"Executes the equivalent of 'get_sql_all' in the current database."
+ from django.core import db
sql_list = get_sql_all(mod)
try:
cursor = db.db.cursor()
@@ -400,8 +406,10 @@ def usage():
ACTION_MAPPING[action](name, os.getcwd())
sys.exit(0)
elif action == 'dbcheck':
+ from django.core import meta
mod_list = meta.get_all_installed_modules()
else:
+ from django.core import meta
try:
mod_list = [meta.get_app(app_label) for app_label in sys.argv[2:]]
except ImportError, e:

0 comments on commit 2b40dee

Please sign in to comment.
Something went wrong with that request. Please try again.