mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 21:40:13 +03:00
Split up section into code blocks
This commit is contained in:
parent
ae71d3aed0
commit
c7801144e9
|
@ -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
|
||||||
mkdir tutorial
|
|
||||||
cd tutorial
|
|
||||||
|
|
||||||
# Create a virtualenv to isolate our package dependencies locally
|
```text
|
||||||
virtualenv env
|
mkdir tutorial
|
||||||
source env/bin/activate # On Windows use `env\Scripts\activate`
|
cd tutorial
|
||||||
|
```
|
||||||
|
|
||||||
# Install Django and Django REST framework into the virtualenv
|
Create a virtualenv to isolate our package dependencies locally
|
||||||
pip install django
|
|
||||||
pip install djangorestframework
|
|
||||||
|
|
||||||
# Set up a new project with a single application
|
```text
|
||||||
django-admin.py startproject tutorial . # Note the trailing '.' character
|
virtualenv env
|
||||||
cd tutorial
|
source env/bin/activate # On Linux or OS X
|
||||||
django-admin.py startapp quickstart
|
source env\Scripts\activate # On Windows
|
||||||
cd ..
|
```
|
||||||
|
|
||||||
|
Install Django and Django REST framework into the virtualenv
|
||||||
|
|
||||||
|
```text
|
||||||
|
pip install django
|
||||||
|
pip install djangorestframework
|
||||||
|
```
|
||||||
|
|
||||||
|
Set up a new project with a single application
|
||||||
|
|
||||||
|
```text
|
||||||
|
django-admin.py startproject tutorial . # Note the trailing '.' character
|
||||||
|
|
||||||
|
cd tutorial
|
||||||
|
django-admin.py startapp quickstart
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
### Database
|
||||||
|
|
||||||
Now sync your database for the first time:
|
Now sync your database for the first time:
|
||||||
|
|
||||||
python manage.py migrate
|
```text
|
||||||
|
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.
|
||||||
|
|
||||||
python manage.py createsuperuser
|
```text
|
||||||
|
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...
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user