Book Image

Mastering Django: Core

By : Nigel George
Book Image

Mastering Django: Core

By: Nigel George

Overview of this book

Mastering Django: Core is a completely revised and updated version of the original Django Book, written by Adrian Holovaty and Jacob Kaplan-Moss - the creators of Django. The main goal of this book is to make you a Django expert. By reading this book, you’ll learn the skills needed to develop powerful websites quickly, with code that is clean and easy to maintain. This book is also a programmer’s manual that provides complete coverage of the current Long Term Support (LTS) version of Django. For developers creating applications for commercial and business critical deployments, Mastering Django: Core provides a complete, up-to-date resource for Django 1.8LTS with a stable code-base, security fixes and support out to 2018.
Table of Contents (33 chapters)
Mastering Django: Core
Credits
About the Author
www.PacktPub.com
Preface
Free Chapter
1
Introduction to Django and Getting Started

Configuring the database


With all of that philosophy in mind, let's start exploring Django's database layer. First, let's explore the initial configuration that was added to settings.py when we created the application:

# Database 
#  
DATABASES = { 
    'default': { 
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
    } 
} 

The default setup is pretty simple. Here's a rundown of each setting.

  • ENGINE: It tells Django which database engine to use. As we are using SQLite in the examples in this book, we will leave it to the default django.db.backends.sqlite3.

  • NAME: It tells Django the name of your database. For example: 'NAME': 'mydb',.

Since we're using SQLite, startproject created a full filesystem path to the database file for us.

This is it for the default setup-you don't need to change anything to run the code in this book, I have included this simply to give you an idea of how simple it is to...