mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #24358 -- Corrected code-block directives for console sessions.
This commit is contained in:
parent
ea3168dc6c
commit
eba6dff581
17 changed files with 100 additions and 134 deletions
|
@ -56,7 +56,7 @@ First, create a spatial database for your project.
|
|||
If you are using PostGIS, create the database from the :ref:`spatial database
|
||||
template <spatialdb_template>`:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ createdb -T template_postgis geodjango
|
||||
|
||||
|
@ -66,7 +66,7 @@ template <spatialdb_template>`:
|
|||
create a database. To create a user with ``CREATE DATABASE`` privileges in
|
||||
PostgreSQL, use the following commands:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ sudo su - postgres
|
||||
$ createuser --createdb geo
|
||||
|
@ -84,14 +84,14 @@ Create a New Project
|
|||
Use the standard ``django-admin`` script to create a project called
|
||||
``geodjango``:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ django-admin startproject geodjango
|
||||
|
||||
This will initialize a new project. Now, create a ``world`` Django application
|
||||
within the ``geodjango`` project:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ cd geodjango
|
||||
$ python manage.py startapp world
|
||||
|
@ -137,7 +137,7 @@ The world borders data is available in this `zip file`__. Create a ``data``
|
|||
directory in the ``world`` application, download the world borders data, and
|
||||
unzip. On GNU/Linux platforms, use the following commands:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ mkdir world/data
|
||||
$ cd world/data
|
||||
|
@ -166,7 +166,7 @@ Use ``ogrinfo`` to examine spatial data
|
|||
The GDAL ``ogrinfo`` utility allows examining the metadata of shapefiles or
|
||||
other vector data sources:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
|
||||
INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp'
|
||||
|
@ -177,7 +177,7 @@ other vector data sources:
|
|||
layer contains polygon data. To find out more, we'll specify the layer name
|
||||
and use the ``-so`` option to get only the important summary information:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ ogrinfo -so world/data/TM_WORLD_BORDERS-0.3.shp TM_WORLD_BORDERS-0.3
|
||||
INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp'
|
||||
|
@ -267,7 +267,7 @@ Run ``migrate``
|
|||
After defining your model, you need to sync it with the database. First,
|
||||
create a database migration:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py makemigrations
|
||||
Migrations for 'world':
|
||||
|
@ -277,7 +277,7 @@ create a database migration:
|
|||
Let's look at the SQL that will generate the table for the ``WorldBorder``
|
||||
model:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py sqlmigrate world 0001
|
||||
|
||||
|
@ -314,7 +314,7 @@ This command should produce the following output:
|
|||
If this looks correct, run :djadmin:`migrate` to create this table in the
|
||||
database:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py migrate
|
||||
Operations to perform:
|
||||
|
@ -351,7 +351,7 @@ library that can work with all the vector data sources that OGR supports.
|
|||
|
||||
First, invoke the Django shell:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py shell
|
||||
|
||||
|
@ -515,7 +515,7 @@ A few notes about what's going on:
|
|||
|
||||
Afterwards, invoke the Django shell from the ``geodjango`` project directory:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py shell
|
||||
|
||||
|
@ -537,7 +537,7 @@ and generates a model definition and ``LayerMapping`` dictionary automatically.
|
|||
|
||||
The general usage of the command goes as follows:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py ogrinspect [options] <data_source> <model_name> [options]
|
||||
|
||||
|
@ -548,7 +548,7 @@ be used to further define how the model is generated.
|
|||
For example, the following command nearly reproduces the ``WorldBorder`` model
|
||||
and mapping dictionary created above, automatically:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py ogrinspect world/data/TM_WORLD_BORDERS-0.3.shp WorldBorder \
|
||||
--srid=4326 --mapping --multi
|
||||
|
@ -609,7 +609,7 @@ GeoDjango adds spatial lookups to the Django ORM. For example, you
|
|||
can find the country in the ``WorldBorder`` table that contains
|
||||
a particular point. First, fire up the management shell:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py shell
|
||||
|
||||
|
@ -753,13 +753,13 @@ Next, edit your ``urls.py`` in the ``geodjango`` application folder as follows::
|
|||
|
||||
Create an admin user:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py createsuperuser
|
||||
|
||||
Next, start up the Django development server:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: console
|
||||
|
||||
$ python manage.py runserver
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue