Commit bc8671d7 by Tom Christie

More explicit quickstart guide. Closes #867.

parent 7c945b43
...@@ -2,7 +2,43 @@ ...@@ -2,7 +2,43 @@
We're going to create a simple API to allow admin users to view and edit the users and groups in the system. We're going to create a simple API to allow admin users to view and edit the users and groups in the system.
Create a new Django project, and start a new app called `quickstart`. Once you've set up a database and got everything synced and ready to go open up the app's directory and we'll get coding... ## Project setup
Create a new Django project named `tutorial`, then start a new app called `quickstart`.
# Set up a new project
django-admin.py startproject tutorial
cd tutorial
# Create a virtualenv to isolate our package dependancies locally
virtualenv env
source env/bin/activate
# Install Django and Django REST framework into the virtualenv
pip install django
pip install djangorestframework
# Create a new app
python manage.py startapp quickstart
Next you'll need to get a database set up and synced. If you just want to use SQLite for now, then you'll want to edit your `tutorial/settings.py` module to include something like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'database.sql',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}
The run `syncdb` like so:
python manange.py syncdb
Once you've set up a database and got everything synced and ready to go, open up the app's directory and we'll get coding...
## Serializers ## Serializers
...@@ -80,7 +116,7 @@ Finally, we're including default login and logout views for use with the browsab ...@@ -80,7 +116,7 @@ Finally, we're including default login and logout views for use with the browsab
## Settings ## Settings
We'd also like to set a few global settings. We'd like to turn on pagination, and we want our API to only be accessible to admin users. We'd also like to set a few global settings. We'd like to turn on pagination, and we want our API to only be accessible to admin users. The settings module will be in `tutorial/settings.py`
INSTALLED_APPS = ( INSTALLED_APPS = (
... ...
...@@ -98,6 +134,10 @@ Okay, we're done. ...@@ -98,6 +134,10 @@ Okay, we're done.
## Testing our API ## Testing our API
We're now ready to test the API we've built. Let's fire up the server from the command line.
python ./manage.py runserver
We can now access our API, both from the command-line, using tools like `curl`... We can now access our API, both from the command-line, using tools like `curl`...
bash: curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/ bash: curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment