From ff246fcf61912960fcd2c859f020d602676c66ea Mon Sep 17 00:00:00 2001 From: Sylvain Le Bon <sylvain@happy-dev.fr> Date: Tue, 8 May 2018 21:10:58 +0000 Subject: [PATCH] Update README.md --- README.md | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2776f1f6..01924624 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,55 @@ It aims at enabling people with little development skills to serve their own dat ## Installation -1. Add this module to your application, or place it in a directory included in your PYTHONPATH -2. Create your model normally +1. Install this module and all its dependencies + +``` +pip install djangoldp +``` + +2. Create a django project + +``` +django-admin startproject myldpserver +``` + +3. Create your django model inside a file myldpserver/myldpserver/models.py + +``` +from django.db import models + +class Todo(models.Model): + name = models.CharField(max_length=255) + deadline = models.DateTimeField() + +``` + + 3. Add a url in your urls.py: ``` from djangoldp.views import LDPViewSet -from .models import MyModel +from .models import Todo urlpatterns = [ - url(r'^my-model/', include(LDPViewSet.urls(model=MyModel))), + url(r'^todos/', include(LDPViewSet.urls(model=Todo))), url(r'^admin/', admin.site.urls), ] ``` This creates 2 routes, one for the list, and one with an ID listing the detail of an object. +4. You can also register your model for the django administration site + +``` +from django.contrib import admin +from .models import Todo + +admin.site.register(Todo) +``` + +5. You then need to have your WSGI server pointing on myldpserver/myldpserver/wsgi.py + ## Execution To start the server, `cd` to the root of your Django project and run : ``` -- GitLab