Fixed #21116 -- Made usage of manage.py in docs more consistent.
Thanks daniel.quattro at gmail.com for the report.
This commit is contained in:
parent
2daada800f
commit
d1c9802811
|
@ -36,11 +36,11 @@ Django comes with a utility called :djadmin:`inspectdb` that can create models
|
||||||
by introspecting an existing database. You can view the output by running this
|
by introspecting an existing database. You can view the output by running this
|
||||||
command::
|
command::
|
||||||
|
|
||||||
python manage.py inspectdb
|
$ python manage.py inspectdb
|
||||||
|
|
||||||
Save this as a file by using standard Unix output redirection::
|
Save this as a file by using standard Unix output redirection::
|
||||||
|
|
||||||
python manage.py inspectdb > models.py
|
$ python manage.py inspectdb > models.py
|
||||||
|
|
||||||
This feature is meant as a shortcut, not as definitive model generation. See the
|
This feature is meant as a shortcut, not as definitive model generation. See the
|
||||||
:djadmin:`documentation of inspectdb <inspectdb>` for more information.
|
:djadmin:`documentation of inspectdb <inspectdb>` for more information.
|
||||||
|
@ -59,12 +59,12 @@ this generated model definition:
|
||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
class Person(models.Model):
|
class Person(models.Model):
|
||||||
id = models.IntegerField(primary_key=True)
|
id = models.IntegerField(primary_key=True)
|
||||||
first_name = models.CharField(max_length=70)
|
first_name = models.CharField(max_length=70)
|
||||||
class Meta:
|
class Meta:
|
||||||
**managed = False**
|
**managed = False**
|
||||||
db_table = 'CENSUS_PERSONS'
|
db_table = 'CENSUS_PERSONS'
|
||||||
|
|
||||||
If you wanted to modify existing data on your ``CENSUS_PERSONS`` SQL table
|
If you wanted to modify existing data on your ``CENSUS_PERSONS`` SQL table
|
||||||
with Django you'd need to change the ``managed`` option highlighted above to
|
with Django you'd need to change the ``managed`` option highlighted above to
|
||||||
|
@ -84,7 +84,7 @@ Install the core Django tables
|
||||||
Next, run the :djadmin:`migrate` command to install any extra needed database
|
Next, run the :djadmin:`migrate` command to install any extra needed database
|
||||||
records such as admin permissions and content types::
|
records such as admin permissions and content types::
|
||||||
|
|
||||||
python manage.py migrate
|
$ python manage.py migrate
|
||||||
|
|
||||||
Test and tweak
|
Test and tweak
|
||||||
==============
|
==============
|
||||||
|
|
|
@ -174,7 +174,7 @@ for gathering static files in a single directory so you can serve them easily.
|
||||||
|
|
||||||
2. Run the :djadmin:`collectstatic` management command::
|
2. Run the :djadmin:`collectstatic` management command::
|
||||||
|
|
||||||
./manage.py collectstatic
|
$ python manage.py collectstatic
|
||||||
|
|
||||||
This will copy all files from your static folders into the
|
This will copy all files from your static folders into the
|
||||||
:setting:`STATIC_ROOT` directory.
|
:setting:`STATIC_ROOT` directory.
|
||||||
|
|
|
@ -76,7 +76,7 @@ manually using ``manage.py runserver``):
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python -Wall manage.py test
|
$ python -Wall manage.py test
|
||||||
|
|
||||||
After you have run the tests, fix any failures. While you have the release
|
After you have run the tests, fix any failures. While you have the release
|
||||||
notes fresh in your mind, it may also be a good time to take advantage of new
|
notes fresh in your mind, it may also be a good time to take advantage of new
|
||||||
|
|
|
@ -53,7 +53,7 @@ automatically:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
manage.py migrate
|
$ python manage.py migrate
|
||||||
|
|
||||||
The :djadmin:`migrate` command looks at all your available models and creates
|
The :djadmin:`migrate` command looks at all your available models and creates
|
||||||
tables in your database for whichever tables don't already exist, as well as
|
tables in your database for whichever tables don't already exist, as well as
|
||||||
|
|
|
@ -169,7 +169,7 @@ It worked!
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py runserver 8080
|
$ python manage.py runserver 8080
|
||||||
|
|
||||||
If you want to change the server's IP, pass it along with the port. So to
|
If you want to change the server's IP, pass it along with the port. So to
|
||||||
listen on all public IPs (useful if you want to show off your work on other
|
listen on all public IPs (useful if you want to show off your work on other
|
||||||
|
@ -177,7 +177,7 @@ It worked!
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py runserver 0.0.0.0:8000
|
$ python manage.py runserver 0.0.0.0:8000
|
||||||
|
|
||||||
Full docs for the development server can be found in the
|
Full docs for the development server can be found in the
|
||||||
:djadmin:`runserver` reference.
|
:djadmin:`runserver` reference.
|
||||||
|
@ -256,7 +256,7 @@ that, run the following command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py syncdb
|
$ python manage.py syncdb
|
||||||
|
|
||||||
The :djadmin:`syncdb` command looks at the :setting:`INSTALLED_APPS` setting
|
The :djadmin:`syncdb` command looks at the :setting:`INSTALLED_APPS` setting
|
||||||
and creates any necessary database tables according to the database settings
|
and creates any necessary database tables according to the database settings
|
||||||
|
@ -308,7 +308,7 @@ and type this command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py startapp polls
|
$ python manage.py startapp polls
|
||||||
|
|
||||||
That'll create a directory :file:`polls`, which is laid out like this::
|
That'll create a directory :file:`polls`, which is laid out like this::
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ Now Django knows to include the ``polls`` app. Let's run another command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py sql polls
|
$ python manage.py sql polls
|
||||||
|
|
||||||
You should see something similar to the following (the ``CREATE TABLE`` SQL
|
You should see something similar to the following (the ``CREATE TABLE`` SQL
|
||||||
statements for the polls app):
|
statements for the polls app):
|
||||||
|
@ -501,7 +501,7 @@ Now, run :djadmin:`syncdb` again to create those model tables in your database:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py syncdb
|
$ python manage.py syncdb
|
||||||
|
|
||||||
The :djadmin:`syncdb` command runs the SQL from :djadmin:`sqlall` on your
|
The :djadmin:`syncdb` command runs the SQL from :djadmin:`sqlall` on your
|
||||||
database for all apps in :setting:`INSTALLED_APPS` that don't already exist in
|
database for all apps in :setting:`INSTALLED_APPS` that don't already exist in
|
||||||
|
@ -521,7 +521,7 @@ API Django gives you. To invoke the Python shell, use this command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py shell
|
$ python manage.py shell
|
||||||
|
|
||||||
We're using this instead of simply typing "python", because :file:`manage.py`
|
We're using this instead of simply typing "python", because :file:`manage.py`
|
||||||
sets the ``DJANGO_SETTINGS_MODULE`` environment variable, which gives Django
|
sets the ``DJANGO_SETTINGS_MODULE`` environment variable, which gives Django
|
||||||
|
|
|
@ -31,7 +31,7 @@ Recall from Tutorial 1 that you start the development server like so:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
python manage.py runserver
|
$ python manage.py runserver
|
||||||
|
|
||||||
Now, open a Web browser and go to "/admin/" on your local domain -- e.g.,
|
Now, open a Web browser and go to "/admin/" on your local domain -- e.g.,
|
||||||
http://127.0.0.1:8000/admin/. You should see the admin's login screen:
|
http://127.0.0.1:8000/admin/. You should see the admin's login screen:
|
||||||
|
|
|
@ -190,7 +190,7 @@ Running tests
|
||||||
|
|
||||||
In the terminal, we can run our test::
|
In the terminal, we can run our test::
|
||||||
|
|
||||||
python manage.py test polls
|
$ python manage.py test polls
|
||||||
|
|
||||||
and you'll see something like::
|
and you'll see something like::
|
||||||
|
|
||||||
|
|
|
@ -499,14 +499,13 @@ Afterwards, invoke the Django shell from the ``geodjango`` project directory:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ python manage.py shell
|
$ python manage.py shell
|
||||||
|
|
||||||
Next, import the ``load`` module, call the ``run`` routine, and watch
|
Next, import the ``load`` module, call the ``run`` routine, and watch
|
||||||
``LayerMapping`` do the work::
|
``LayerMapping`` do the work::
|
||||||
|
|
||||||
>>> from world import load
|
>>> from world import load
|
||||||
>>> load.run()
|
>>> load.run()
|
||||||
|
|
||||||
|
|
||||||
.. _ogrinspect-intro:
|
.. _ogrinspect-intro:
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ first time you run it with ``'django.contrib.auth'`` in your
|
||||||
:setting:`INSTALLED_APPS`. If you need to create a superuser at a later date,
|
:setting:`INSTALLED_APPS`. If you need to create a superuser at a later date,
|
||||||
you can use a command line utility::
|
you can use a command line utility::
|
||||||
|
|
||||||
manage.py createsuperuser --username=joe --email=joe@example.com
|
$ python manage.py createsuperuser --username=joe --email=joe@example.com
|
||||||
|
|
||||||
You will be prompted for a password. After you enter one, the user will be
|
You will be prompted for a password. After you enter one, the user will be
|
||||||
created immediately. If you leave off the :djadminopt:`--username` or the
|
created immediately. If you leave off the :djadminopt:`--username` or the
|
||||||
|
|
|
@ -162,7 +162,7 @@ Database caching
|
||||||
To use a database table as your cache backend, first create a cache table in
|
To use a database table as your cache backend, first create a cache table in
|
||||||
your database by running this command::
|
your database by running this command::
|
||||||
|
|
||||||
python manage.py createcachetable [cache_table_name]
|
$ python manage.py createcachetable [cache_table_name]
|
||||||
|
|
||||||
...where ``[cache_table_name]`` is the name of the database table to create.
|
...where ``[cache_table_name]`` is the name of the database table to create.
|
||||||
(This name can be whatever you want, as long as it's a valid table name that's
|
(This name can be whatever you want, as long as it's a valid table name that's
|
||||||
|
|
|
@ -255,7 +255,7 @@ If your app already has models and database tables, and doesn't have migrations
|
||||||
yet (for example, you created it against a previous Django version), you'll
|
yet (for example, you created it against a previous Django version), you'll
|
||||||
need to convert it to use migrations; this is a simple process::
|
need to convert it to use migrations; this is a simple process::
|
||||||
|
|
||||||
python manage.py makemigrations yourappname
|
$ python manage.py makemigrations yourappname
|
||||||
|
|
||||||
This will make a new initial migration for your app. Now, when you run
|
This will make a new initial migration for your app. Now, when you run
|
||||||
:djadmin:`migrate`, Django will detect that you have an initial migration
|
:djadmin:`migrate`, Django will detect that you have an initial migration
|
||||||
|
|
Loading…
Reference in New Issue