Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Chapter05 #14

Merged
merged 4 commits into from over 1 year ago

2 participants

Jacob Silva Jacob Kaplan-Moss
Jacob Silva

Minor updates to Chapter05.
The link 'next chapter' wasn't going to Chapter 06
Updated DB configs to reflect 1.4

Jacob Silva Funkmyster commented on the diff November 04, 2012
chapter05.rst
@@ -1380,7 +1384,5 @@ user-submitted form data.
1380 1384
 
1381 1385
 But in some cases, you or your team might need to enter data manually, in which
1382 1386
 case it would be helpful to have a Web-based interface for entering and
1383  
-managing data. The `next chapter`_ covers Django's admin interface, which exists
  1387
+managing data. The :doc:`next chapter <chapter06>` covers Django's admin interface, which exists
1

Changed relative link to the format used at the end of Chapter04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
chapter05.rst
((4 lines not shown))
179  
-    DATABASE_ENGINE = ''
180  
-    DATABASE_NAME = ''
181  
-    DATABASE_USER = ''
182  
-    DATABASE_PASSWORD = ''
183  
-    DATABASE_HOST = ''
184  
-    DATABASE_PORT = ''
  179
+    DATABASES = {
  180
+        'default': {
  181
+            'ENGINE': '',
  182
+            'NAME': '',
  183
+            'USER': '',
  184
+            'PASSWORD': '',
  185
+            'HOST': '',
  186
+            'PORT': '',
  187
+        },
  188
+    }
1
Jacob Kaplan-Moss Owner

This should probably use the exact snippet from the generated config file (i.e. with comments, etc.) instead of something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
chapter05.rst
((27 lines not shown))
190 194
   the strings shown in Table 5-1.
191 195
 
192 196
   .. table:: Table 5-1. Database Engine Settings
193 197
 
194  
-      =======================  ====================  ==============================================
195  
-      Setting                  Database              Required Adapter
196  
-      =======================  ====================  ==============================================
197  
-      ``postgresql``           PostgreSQL            ``psycopg`` version 1.x,
198  
-                                                     http://www.djangoproject.com/r/python-pgsql/1/.
  198
+      ============================================ ============ ================================================
  199
+      Setting                                      Database     Required Adapter
  200
+      ============================================ ============ ================================================
  201
+      ``django.db.backends.postgresql``            PostgreSQL   ``psycopg`` version 1.x,
  202
+                                                                http://www.djangoproject.com/r/python-pgsql/1/.
1
Jacob Kaplan-Moss Owner

This backend's been deprecated in favor of the psycopg2 one; we shouldn't mention it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jacob Silva Funkmyster commented on the diff November 05, 2012
chapter05.rst
((46 lines not shown))
202 206
 
203  
-      ``mysql``                MySQL                 ``MySQLdb``,
204  
-                                                     http://www.djangoproject.com/r/python-mysql/.
  207
+      ``django.db.backends.sqlite3``               SQLite       No adapter needed.
1

Adapter not needed as of Python 2.5 (minimum version of Django 1.4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jacob Kaplan-Moss jacobian merged commit 1127230 into from November 06, 2012
Jacob Kaplan-Moss jacobian closed this November 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 39 additions and 42 deletions. Show diff stats Hide diff stats

  1. 81  chapter05.rst
81  chapter05.rst
Source Rendered
@@ -176,40 +176,39 @@ As with ``TEMPLATE_DIRS`` in the previous chapter, database configuration lives
176 176
 the Django settings file, called ``settings.py`` by default. Edit that file and
177 177
 look for the database settings::
178 178
 
179  
-    DATABASE_ENGINE = ''
180  
-    DATABASE_NAME = ''
181  
-    DATABASE_USER = ''
182  
-    DATABASE_PASSWORD = ''
183  
-    DATABASE_HOST = ''
184  
-    DATABASE_PORT = ''
  179
+    DATABASES = {
  180
+        'default': {
  181
+            'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
  182
+            'NAME': '',                      # Or path to database file if using sqlite3.
  183
+            'USER': '',                      # Not used with sqlite3.
  184
+            'PASSWORD': '',                  # Not used with sqlite3.
  185
+            'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
  186
+            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  187
+        }
  188
+    }
185 189
 
186 190
 Here's a rundown of each setting.
187 191
 
188  
-* ``DATABASE_ENGINE`` tells Django which database engine to use. If you're
189  
-  using a database with Django, ``DATABASE_ENGINE`` must be set to one of
  192
+* ``ENGINE`` tells Django which database engine to use. If you're
  193
+  using a database with Django, ``ENGINE`` must be set to one of
190 194
   the strings shown in Table 5-1.
191 195
 
192 196
   .. table:: Table 5-1. Database Engine Settings
193 197
 
194  
-      =======================  ====================  ==============================================
195  
-      Setting                  Database              Required Adapter
196  
-      =======================  ====================  ==============================================
197  
-      ``postgresql``           PostgreSQL            ``psycopg`` version 1.x,
198  
-                                                     http://www.djangoproject.com/r/python-pgsql/1/.
  198
+      ============================================ ============ ================================================
  199
+      Setting                                      Database     Required Adapter
  200
+      ============================================ ============ ================================================
  201
+      ``django.db.backends.postgresql_psycopg2``   PostgreSQL   ``psycopg`` version 2.x,
  202
+                                                                http://www.djangoproject.com/r/python-pgsql/.
199 203
 
200  
-      ``postgresql_psycopg2``  PostgreSQL            ``psycopg`` version 2.x,
201  
-                                                     http://www.djangoproject.com/r/python-pgsql/.
  204
+      ``django.db.backends.mysql``                 MySQL        ``MySQLdb``,
  205
+                                                                http://www.djangoproject.com/r/python-mysql/.
202 206
 
203  
-      ``mysql``                MySQL                 ``MySQLdb``,
204  
-                                                     http://www.djangoproject.com/r/python-mysql/.
  207
+      ``django.db.backends.sqlite3``               SQLite       No adapter needed.
205 208
 
206  
-      ``sqlite3``              SQLite                No adapter needed if using Python 2.5+.
207  
-                                                     Otherwise, ``pysqlite``,
208  
-                                                     http://www.djangoproject.com/r/python-sqlite/.
209  
-
210  
-      ``oracle``               Oracle                ``cx_Oracle``,
211  
-                                                     http://www.djangoproject.com/r/python-oracle/.
212  
-      =======================  ====================  ==============================================
  209
+      ``django.db.backends.oracle``                Oracle       ``cx_Oracle``,
  210
+                                                                http://www.djangoproject.com/r/python-oracle/.
  211
+      ============================================ ============ ================================================
213 212
 
214 213
   Note that for whichever database back-end you use, you'll need to download
215 214
   and install the appropriate database adapter. Each one is available for
@@ -220,29 +219,29 @@ Here's a rundown of each setting.
220 219
 
221 220
   Example::
222 221
 
223  
-      DATABASE_ENGINE = 'postgresql_psycopg2'
  222
+      'ENGINE': 'django.db.backends.postgresql_psycopg2',
224 223
 
225  
-* ``DATABASE_NAME`` tells Django the name of your database. For example::
  224
+* ``NAME`` tells Django the name of your database. For example::
226 225
 
227  
-      DATABASE_NAME = 'mydb'
  226
+      'NAME': 'mydb',
228 227
 
229 228
   If you're using SQLite, specify the full filesystem path to the database
230 229
   file on your filesystem. For example::
231 230
 
232  
-      DATABASE_NAME = '/home/django/mydata.db'
  231
+      'NAME': '/home/django/mydata.db',
233 232
 
234 233
   As for where you put that SQLite database, we're using the ``/home/django``
235 234
   directory in this example, but you should pick a directory that works
236 235
   best for you.
237 236
 
238  
-* ``DATABASE_USER`` tells Django which username to use when connecting to
  237
+* ``USER`` tells Django which username to use when connecting to
239 238
   your database. For example: If you're using SQLite, leave this blank.
240 239
 
241  
-* ``DATABASE_PASSWORD`` tells Django which password to use when connecting
  240
+* ``PASSWORD`` tells Django which password to use when connecting
242 241
   to your database. If you're using SQLite or have an empty password, leave
243 242
   this blank.
244 243
 
245  
-* ``DATABASE_HOST`` tells Django which host to use when connecting to your
  244
+* ``HOST`` tells Django which host to use when connecting to your
246 245
   database. If your database is on the same computer as your Django
247 246
   installation (i.e., localhost), leave this blank. If you're using SQLite,
248 247
   leave this blank.
@@ -251,7 +250,7 @@ Here's a rundown of each setting.
251 250
   (``'/'``) and you're using MySQL, MySQL will connect via a Unix socket to
252 251
   the specified socket, for example::
253 252
 
254  
-      DATABASE_HOST = '/var/run/mysql'
  253
+      'HOST': '/var/run/mysql',
255 254
 
256 255
 .. SL The usual convention is for the socket to be named 'mysql.sock' or similar,
257 256
 .. SL so would '/var/run/mysql.sock' be a better example?
@@ -259,7 +258,7 @@ Here's a rundown of each setting.
259 258
   If you're using MySQL and this value *doesn't* start with a forward
260 259
   slash, then this value is assumed to be the host.
261 260
 
262  
-* ``DATABASE_PORT`` tells Django which port to use when connecting to your
  261
+* ``PORT`` tells Django which port to use when connecting to your
263 262
   database. If you're using SQLite, leave this blank. Otherwise, if you
264 263
   leave this blank, the underlying database adapter will use whichever
265 264
   port is default for your given database server. In most cases, the
@@ -286,7 +285,7 @@ the error message for clues about what's wrong. Table 5-2 shows some common erro
286 285
     =========================================================  ===============================================
287 286
     Error Message                                              Solution
288 287
     =========================================================  ===============================================
289  
-    You haven't set the DATABASE_ENGINE setting yet.           Set the ``DATABASE_ENGINE`` setting to
  288
+    You haven't set the ENGINE setting yet.                    Set the ``ENGINE`` setting to
290 289
                                                                something other than an empty string. Valid
291 290
                                                                values are in Table 5-1.
292 291
     Environment variable DJANGO_SETTINGS_MODULE is undefined.  Run the command ``python manage.py shell``
@@ -296,19 +295,19 @@ the error message for clues about what's wrong. Table 5-2 shows some common erro
296 295
                                                                or ``MySQLdb``). Adapters are *not* bundled
297 296
                                                                with Django, so it's your responsibility to
298 297
                                                                download and install them on your own.
299  
-    _____ isn't an available database backend.                 Set your ``DATABASE_ENGINE`` setting to
  298
+    _____ isn't an available database backend.                 Set your ``ENGINE`` setting to
300 299
                                                                one of the valid engine settings described
301 300
                                                                previously. Perhaps you made a typo?
302  
-    database _____ does not exist                              Change the ``DATABASE_NAME`` setting to
  301
+    database _____ does not exist                              Change the ``NAME`` setting to
303 302
                                                                point to a database that exists, or
304 303
                                                                execute the appropriate
305 304
                                                                ``CREATE DATABASE`` statement in order to
306 305
                                                                create it.
307  
-    role _____ does not exist                                  Change the ``DATABASE_USER`` setting to point
  306
+    role _____ does not exist                                  Change the ``USER`` setting to point
308 307
                                                                to a user that exists, or create the user
309 308
                                                                in your database.
310  
-    could not connect to server                                Make sure ``DATABASE_HOST`` and
311  
-                                                               ``DATABASE_PORT`` are set correctly, and
  309
+    could not connect to server                                Make sure ``HOST`` and
  310
+                                                               ``PORT`` are set correctly, and
312 311
                                                                make sure the database server is running.
313 312
     =========================================================  ===============================================
314 313
 
@@ -1380,7 +1379,5 @@ user-submitted form data.
1380 1379
 
1381 1380
 But in some cases, you or your team might need to enter data manually, in which
1382 1381
 case it would be helpful to have a Web-based interface for entering and
1383  
-managing data. The `next chapter`_ covers Django's admin interface, which exists
  1382
+managing data. The :doc:`next chapter <chapter06>` covers Django's admin interface, which exists
1384 1383
 precisely for that reason.
1385  
-
1386  
-.. _next chapter: ../chapter06/
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.