Skip to content

Commit 442998c

Browse files
author
Adam Charnock
committed
Adding Readme file to cookbook example project
1 parent 716aa8f commit 442998c

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

examples/cookbook/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Cookbook Example Django Project
2+
===============================
3+
4+
This example project demos integration between Graphene and Django.
5+
The project contains two apps, one named `ingredients` and another
6+
named `recepies`.
7+
8+
Getting started
9+
---------------
10+
11+
First you'll need to get the source of the project. Do this by cloning the
12+
whole Graphene repository:
13+
14+
```bash
15+
# Get the example project code
16+
git clone https://github.com/graphql-python/graphene.git
17+
cd graphene/examples/cookbook
18+
```
19+
20+
It is good idea (but not required) to create a virtual environment
21+
for this project. We'll do this using
22+
[virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/)
23+
to keep things simple,
24+
but you may also find something like
25+
[virtualenvwrapper](https://virtualenvwrapper.readthedocs.org/en/latest/)
26+
to be useful:
27+
28+
```bash
29+
# Create a virtualenv in which we can install the dependencies
30+
virtualenv env
31+
source env/bin/activate
32+
```
33+
34+
Now we can install our dependencies:
35+
36+
```bash
37+
pip install -r requirements.txt
38+
```
39+
40+
Now setup our database:
41+
42+
```bash
43+
# Setup the database
44+
./manage.py migrate
45+
46+
# Load some example data
47+
./manage.py loaddata ingredients
48+
49+
# Create an admin user (useful for logging into the admin UI
50+
# at http://127.0.0.1:8000/admin)
51+
./manage.py createsuperuser
52+
```
53+
54+
Now you should be ready to start the server:
55+
56+
```bash
57+
./manage.py runserver
58+
```
59+
60+
Now head on over to
61+
[http://127.0.0.1:8000/graphiql](http://127.0.0.1:8000/graphiql)
62+
and run some queries!
63+
(See the [Django quickstart guide](http://graphene-python.org/docs/quickstart-django/)
64+
for some example queries)

examples/cookbook/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-e git+https://github.com/adamcharnock/graphene.git@feature/django#egg=graphene
2-
graphql-core==0.4.12
1+
graphene[django]
2+
django_graphiql
3+
graphql-core
34
django==1.9
4-
django_graphiql==0.4.2
55
django-filter==0.11.0

0 commit comments

Comments
 (0)