Fixed #454 -- Clarified django-admin '--help' output to use 'modelmodule' instead of 'app'. Thanks, Maniac

git-svn-id: http://code.djangoproject.com/svn/django/trunk@607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-09-02 18:26:16 +00:00
parent fe66d3b83b
commit 59b204526e
2 changed files with 34 additions and 34 deletions

View File

@ -12,7 +12,7 @@ MODULE_TEMPLATE = ''' {%% if perms.%(app)s.%(addperm)s or perms.%(app)s.%(cha
</tr> </tr>
{%% endif %%}''' {%% endif %%}'''
APP_ARGS = '[app app ...]' APP_ARGS = '[modelmodule ...]'
# Use django.__path__[0] because we don't know which directory django into # Use django.__path__[0] because we don't know which directory django into
# which has been installed. # which has been installed.
@ -101,7 +101,7 @@ def get_sql_create(mod):
table_output.append(');') table_output.append(');')
final_output.append('\n'.join(table_output)) final_output.append('\n'.join(table_output))
return final_output return final_output
get_sql_create.help_doc = "Prints the CREATE TABLE SQL statements for the given app(s)." get_sql_create.help_doc = "Prints the CREATE TABLE SQL statements for the given model module name(s)."
get_sql_create.args = APP_ARGS get_sql_create.args = APP_ARGS
def get_sql_delete(mod): def get_sql_delete(mod):
@ -147,13 +147,13 @@ def get_sql_delete(mod):
output.append("DELETE FROM auth_admin_log WHERE content_type_id = %s;" % row[0]) output.append("DELETE FROM auth_admin_log WHERE content_type_id = %s;" % row[0])
return output[::-1] # Reverse it, to deal with table dependencies. return output[::-1] # Reverse it, to deal with table dependencies.
get_sql_delete.help_doc = "Prints the DROP TABLE SQL statements for the given app(s)." get_sql_delete.help_doc = "Prints the DROP TABLE SQL statements for the given model module name(s)."
get_sql_delete.args = APP_ARGS get_sql_delete.args = APP_ARGS
def get_sql_reset(mod): def get_sql_reset(mod):
"Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module." "Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module."
return get_sql_delete(mod) + get_sql_all(mod) return get_sql_delete(mod) + get_sql_all(mod)
get_sql_reset.help_doc = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app(s)." get_sql_reset.help_doc = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given model module name(s)."
get_sql_reset.args = APP_ARGS get_sql_reset.args = APP_ARGS
def get_sql_initial_data(mod): def get_sql_initial_data(mod):
@ -176,7 +176,7 @@ def get_sql_initial_data(mod):
for codename, name in _get_all_permissions(opts): for codename, name in _get_all_permissions(opts):
output.append(_get_permission_insert(name, codename, opts)) output.append(_get_permission_insert(name, codename, opts))
return output return output
get_sql_initial_data.help_doc = "Prints the initial INSERT SQL statements for the given app(s)." get_sql_initial_data.help_doc = "Prints the initial INSERT SQL statements for the given model module name(s)."
get_sql_initial_data.args = APP_ARGS get_sql_initial_data.args = APP_ARGS
def get_sql_sequence_reset(mod): def get_sql_sequence_reset(mod):
@ -188,7 +188,7 @@ def get_sql_sequence_reset(mod):
if isinstance(f, meta.AutoField): if isinstance(f, meta.AutoField):
output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % (klass._meta.db_table, f.column, f.column, klass._meta.db_table)) output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % (klass._meta.db_table, f.column, f.column, klass._meta.db_table))
return output return output
get_sql_sequence_reset.help_doc = "Prints the SQL statements for resetting PostgreSQL sequences for the given app(s)." get_sql_sequence_reset.help_doc = "Prints the SQL statements for resetting PostgreSQL sequences for the given model module name(s)."
get_sql_sequence_reset.args = APP_ARGS get_sql_sequence_reset.args = APP_ARGS
def get_sql_indexes(mod): def get_sql_indexes(mod):
@ -201,13 +201,13 @@ def get_sql_indexes(mod):
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, klass._meta.db_table, f.column)) (unique, klass._meta.db_table, f.column, klass._meta.db_table, f.column))
return output return output
get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given app(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
def get_sql_all(mod): def get_sql_all(mod):
"Returns a list of CREATE TABLE SQL and initial-data insert for the given module." "Returns a list of CREATE TABLE SQL and initial-data insert for the given module."
return get_sql_create(mod) + get_sql_initial_data(mod) return get_sql_create(mod) + get_sql_initial_data(mod)
get_sql_all.help_doc = "Prints the CREATE TABLE and initial-data SQL statements for the given app(s)." get_sql_all.help_doc = "Prints the CREATE TABLE and initial-data SQL statements for the given model module name(s)."
get_sql_all.args = APP_ARGS get_sql_all.args = APP_ARGS
def database_check(mod): def database_check(mod):
@ -259,7 +259,7 @@ def database_check(mod):
except KeyError: except KeyError:
# sys.stderr.write("A content type called '%s.%s' was found in the database but not in the model.\n" % (app_label, row[0])) # sys.stderr.write("A content type called '%s.%s' was found in the database but not in the model.\n" % (app_label, row[0]))
print "DELETE FROM content_types WHERE package='%s' AND python_module_name = '%s';" % (app_label, row[0]) print "DELETE FROM content_types WHERE package='%s' AND python_module_name = '%s';" % (app_label, row[0])
database_check.help_doc = "Checks that everything is installed in the database for the given app(s) and prints SQL statements if needed." database_check.help_doc = "Checks that everything is installed in the database for the given model module name(s) and prints SQL statements if needed."
database_check.args = APP_ARGS database_check.args = APP_ARGS
def get_admin_index(mod): def get_admin_index(mod):
@ -281,7 +281,7 @@ def get_admin_index(mod):
output.append('</table></div>') output.append('</table></div>')
output.append('{% endif %}') output.append('{% endif %}')
return output return output
get_admin_index.help_doc = "Prints the admin-index template snippet for the given app(s)." get_admin_index.help_doc = "Prints the admin-index template snippet for the given model module name(s)."
get_admin_index.args = APP_ARGS get_admin_index.args = APP_ARGS
def init(): def init():
@ -321,7 +321,7 @@ The full error: %s\n""" % \
db.db.rollback() db.db.rollback()
sys.exit(1) sys.exit(1)
db.db.commit() db.db.commit()
install.help_doc = "Executes ``sqlall`` for the given app(s) in the current database." install.help_doc = "Executes ``sqlall`` for the given model module name(s) in the current database."
install.args = APP_ARGS install.args = APP_ARGS
def _start_helper(app_or_project, name, directory, other_name=''): def _start_helper(app_or_project, name, directory, other_name=''):
@ -376,7 +376,7 @@ startproject.help_doc = "Creates a Django project directory structure for the gi
startproject.args = "[projectname]" startproject.args = "[projectname]"
def startapp(app_name, directory): def startapp(app_name, directory):
"Creates a Django app for the given project_name in the given directory." "Creates a Django app for the given app_name in the given directory."
# Determine the project_name a bit naively -- by looking at the name of # Determine the project_name a bit naively -- by looking at the name of
# the parent directory. # the parent directory.
project_dir = os.path.normpath(os.path.join(directory, '../')) project_dir = os.path.normpath(os.path.join(directory, '../'))

View File

@ -22,18 +22,18 @@ document.
Run ``django-admin.py --help`` to display a help message that includes a terse Run ``django-admin.py --help`` to display a help message that includes a terse
list of all available actions and options. list of all available actions and options.
Most actions take a list of "app"s. An "app," in this case, is the name of Most actions take a list of "modelmodule"s. A "modelmodule," in this case, is
a file containing Django models. For example, if you have a model module called the name of a file containing Django models. For example, if you have a model
``myproject/apps/polls/pollmodels.py``, the "app" in this case would be module called ``myproject/apps/polls/pollmodels.py``, the "modelmodule" in this
``"pollmodels"``. case would be ``"pollmodels"``.
Available actions Available actions
================= =================
adminindex [app app ...] adminindex [modelmodule modelmodule ...]
------------------------ ------------------------
Prints the admin-index template snippet for the given app(s). Prints the admin-index template snippet for the given model module(s).
Use admin-index template snippets if you want to customize the look and feel of Use admin-index template snippets if you want to customize the look and feel of
your admin's index page. See `Tutorial 2`_ for more information. your admin's index page. See `Tutorial 2`_ for more information.
@ -75,10 +75,10 @@ customizations. In particular, you'll need to do this:
``inspectdb`` only works with PostgreSQL and MySQL. Foreign-key detection only ``inspectdb`` only works with PostgreSQL and MySQL. Foreign-key detection only
works in PostgreSQL. works in PostgreSQL.
install [app app ...] install [modelmodule modelmodule ...]
--------------------- ---------------------
Executes the equivalent of ``sqlall`` for the given app(s). Executes the equivalent of ``sqlall`` for the given model module(s).
runserver [optional port number, or ipaddr:port] runserver [optional port number, or ipaddr:port]
------------------------------------------------ ------------------------------------------------
@ -115,41 +115,41 @@ Port 7000 on IP address 1.2.3.4::
django-admin.py runserver 1.2.3.4:7000 django-admin.py runserver 1.2.3.4:7000
sql [app app ...] sql [modelmodule modelmodule ...]
----------------- -----------------
Prints the CREATE TABLE SQL statements for the given app(s). Prints the CREATE TABLE SQL statements for the given model module(s).
sqlall [app app ...] sqlall [modelmodule modelmodule ...]
-------------------- --------------------
Prints the CREATE TABLE and initial-data SQL statements for the given app(s). Prints the CREATE TABLE and initial-data SQL statements for the given model module(s).
sqlclear [app app ...] sqlclear [modelmodule modelmodule ...]
---------------------- ----------------------
Prints the DROP TABLE SQL statements for the given app(s). Prints the DROP TABLE SQL statements for the given model module(s).
sqlindexes [app app ...] sqlindexes [modelmodule modelmodule ...]
------------------------ ------------------------
Prints the CREATE INDEX SQL statements for the given app(s). Prints the CREATE INDEX SQL statements for the given model module(s).
sqlinitialdata [app app ...] sqlinitialdata [modelmodule modelmodule ...]
---------------------------- ----------------------------
Prints the initial INSERT SQL statements for the given app(s). Prints the initial INSERT SQL statements for the given model module(s).
sqlreset [app app ...] sqlreset [modelmodule modelmodule ...]
---------------------- ----------------------
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app(s). Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given model module(s).
sqlsequencereset [app app ...] sqlsequencereset [modelmodule modelmodule ...]
------------------------------ ------------------------------
Prints the SQL statements for resetting PostgreSQL sequences for the given Prints the SQL statements for resetting PostgreSQL sequences for the given
app(s). model module(s).
See http://simon.incutio.com/archive/2004/04/21/postgres for more information. See http://simon.incutio.com/archive/2004/04/21/postgres for more information.