@@ -4,6 +4,8 @@ This module is an add-on for Django REST Framework that serves a django model re
It aims at enabling people with little development skills to serve their own data, to be used with a LDP application.
Building a Startin' Blox application? Read this: https://git.happy-dev.fr/startinblox/devops/doc
## Requirements
* Django (known to work with django 1.11)
...
...
@@ -26,7 +28,18 @@ $ pip install djangoldp
$ django-admin startproject myldpserver
```
3. Create your django model inside a file myldpserver/myldpserver/models.py
3. Add DjangoLDP to INSTALLED_APPS
```python
INSTALLED_APPS=[
...
# make sure all of your own apps are installed BEFORE DjangoLDP
'djangoldp.apps.DjangoldpConfig',
]
```
IMPORTANT: DjangoLDP will register any models which haven't been registered, with the admin. As such it is important to add your own apps above DjangoLDP, so that you can use custom Admin classes if you wish
4. Create your django model inside a file myldpserver/myldpserver/models.py
Note that container_path will be use to resolve instance iri and container iri
In the future it could also be used to auto configure django router (e.g. urls.py)
...
...
@@ -38,14 +51,14 @@ class Todo(Model):
deadline=models.DateTimeField()
```
3.1. Configure container path (optional)
4.1. Configure container path (optional)
By default it will be "todos/" with an S for model called Todo
```python
<Model>._meta.container_path="/my-path/"
```
3.2. Configure field visibility (optional)
4.2. Configure field visibility (optional)
Note that at this stage you can limit access to certain fields of models using
Note that this will be overridden if you explicitly set the fields= parameter as an argument to LDPViewSet.urls(), and filtered if you set the excludes= parameter.
4. Add a url in your urls.py:
5. Add a url in your urls.py:
```python
fromdjango.conf.urlsimporturl
...
...
@@ -86,14 +99,23 @@ You could also only use this line in settings.py instead:
ROOT_URLCONF='djangoldp.urls'
```
5. In the settings.py file, add your application name at the beginning of the application list, and add the following lines
6. In the settings.py file, add your application name at the beginning of the application list, and add the following lines
6. You can also register your model for the django administration site
*`LDP_RDF_CONTEXT` tells DjangoLDP where our RDF [ontology](https://www.w3.org/standards/semanticweb/ontology) is defined, which will be returned as part of our views in the 'context' field. This is a web URL and you can visit the value to view the full ontology online
*`DJANGOLDP_PACKAGES` defines which other [DjangoLDP packages](https://git.happy-dev.fr/startinblox/djangoldp-packages) we're using in this installation
*`SITE_URL` is the URL serving the site, e.g. `https://example.com/`
*`BASE_URL` may be different from SITE_URL, e.g. `https://example.com/app/`
7. You can also register your model for the django administration site
```python
fromdjango.contribimportadmin
...
...
@@ -102,15 +124,15 @@ from .models import Todo
admin.site.register(Todo)
```
7. You then need to have your WSGI server pointing on myldpserver/myldpserver/wsgi.py
8. You then need to have your WSGI server pointing on myldpserver/myldpserver/wsgi.py