Split up section into code blocks

This commit is contained in:
Raphael Pierzina 2016-12-02 15:26:50 +00:00
parent ae71d3aed0
commit c7801144e9

View File

@ -10,33 +10,54 @@ We're going to create a simple API to allow admin users to view and edit the use
## Project setup ## Project setup
Create a new Django project named `tutorial`, then start a new app called `quickstart`. ### Create a new Django project named `tutorial`, then start a new app called `quickstart`.
# Create the project directory Create the project directory
```text
mkdir tutorial mkdir tutorial
cd tutorial cd tutorial
```
# Create a virtualenv to isolate our package dependencies locally Create a virtualenv to isolate our package dependencies locally
```text
virtualenv env virtualenv env
source env/bin/activate # On Windows use `env\Scripts\activate` source env/bin/activate # On Linux or OS X
source env\Scripts\activate # On Windows
```
# Install Django and Django REST framework into the virtualenv Install Django and Django REST framework into the virtualenv
```text
pip install django pip install django
pip install djangorestframework pip install djangorestframework
```
# Set up a new project with a single application Set up a new project with a single application
```text
django-admin.py startproject tutorial . # Note the trailing '.' character django-admin.py startproject tutorial . # Note the trailing '.' character
cd tutorial cd tutorial
django-admin.py startapp quickstart django-admin.py startapp quickstart
cd .. cd ..
```
### Database
Now sync your database for the first time: Now sync your database for the first time:
```text
python manage.py migrate python manage.py migrate
```
We'll also create an initial user named `admin` with a password of `password123`. We'll authenticate as that user later in our example. We'll also create an initial user named `admin` with a password of `password123`. We'll authenticate as that user later in our example.
```text
python manage.py createsuperuser python manage.py createsuperuser
```
Once you've set up a database and initial user created and ready to go, open up the app's directory and we'll get coding... Once you've set up a database and initial user created and ready to go, open up the app's directory and we'll get coding...