Relocated database setup details to install docs to simplify tutorial 2.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
This commit is contained in:
Kudz 2024-04-24 16:31:10 +02:00 committed by nessita
parent 1005c2abd1
commit 82c71f0168
2 changed files with 37 additions and 43 deletions

View file

@ -17,48 +17,15 @@ Database setup
Now, open up :file:`mysite/settings.py`. It's a normal Python module with
module-level variables representing Django settings.
By default, the configuration uses SQLite. If you're new to databases, or
you're just interested in trying Django, this is the easiest choice. SQLite is
included in Python, so you won't need to install anything else to support your
database. When starting your first real project, however, you may want to use a
more scalable database like PostgreSQL, to avoid database-switching headaches
down the road.
By default, the :setting:`DATABASES` configuration uses SQLite. If you're new
to databases, or you're just interested in trying Django, this is the easiest
choice. SQLite is included in Python, so you won't need to install anything
else to support your database. When starting your first real project, however,
you may want to use a more scalable database like PostgreSQL, to avoid
database-switching headaches down the road.
If you wish to use another database, install the appropriate :ref:`database
bindings <database-installation>` and change the following keys in the
:setting:`DATABASES` ``'default'`` item to match your database connection
settings:
* :setting:`ENGINE <DATABASE-ENGINE>` -- Either
``'django.db.backends.sqlite3'``,
``'django.db.backends.postgresql'``,
``'django.db.backends.mysql'``, or
``'django.db.backends.oracle'``. Other backends are :ref:`also available
<third-party-notes>`.
* :setting:`NAME` -- The name of your database. If you're using SQLite, the
database will be a file on your computer; in that case, :setting:`NAME`
should be the full absolute path, including filename, of that file. The
default value, ``BASE_DIR / 'db.sqlite3'``, will store the file in your
project directory.
If you are not using SQLite as your database, additional settings such as
:setting:`USER`, :setting:`PASSWORD`, and :setting:`HOST` must be added.
For more details, see the reference documentation for :setting:`DATABASES`.
.. admonition:: For databases other than SQLite
If you're using a database besides SQLite, make sure you've created a
database by this point. Do that with "``CREATE DATABASE database_name;``"
within your database's interactive prompt.
Also make sure that the database user provided in :file:`mysite/settings.py`
has "create database" privileges. This allows automatic creation of a
:ref:`test database <the-test-database>` which will be needed in a later
tutorial.
If you're using SQLite, you don't need to create anything beforehand - the
database file will be created automatically when it is needed.
If you wish to use another database, see :ref:`details to customize and get
your database running <database-installation>`.
While you're editing :file:`mysite/settings.py`, set :setting:`TIME_ZONE` to
your time zone.