How to develop SIB server packages
LDP packages represent capabilites the server could support. Each may have it’s own configuration depending of what mission it fulfills. There is no limit of what a LDP package can do. Here we are going to see how to developp your own package.
A SIB server in development mode.
Generate your package template
First we retrieve the template of the package with this command :
sib startpackage djangoldp_mypack
All your package should respect this semantic. For example djangoldp_skills.
Make a first model
Go to your models.py file, and make a simple first model :
from django.db import models from djangoldp.models import Model from django.conf import settings class Todo(Model): name = models.CharField(max_length=255) deadline = models.DateTimeField() author_user = models.ForeignKey(settings.AUTH_USER_MODEL) class Meta: auto_author = 'author_user' serializer_fields = ['name']
A section about models is coming soon.
Add your package
Tell your sever, you’ve add a new package in the packages.yml:
ldppackages: djangoldp_mypack: djangoldp_mypack
Initiate your server
Go at the root of your developpement server at the level where reside your manage.py file.
Then initiate your server running this command:
sib install sibserver
Make the migration
At the root of your project, run the following commands :
python manage.py makemigrations python manage.py migrate
Run your server
Finally, you can run your server as usual to see your new package’s data :
python manage.py runserver
Now access to your Django administration http://127.0.0.1:8000/admin/. You should see your Todo model.
To access to the jsonLD API, go to http://127.0.0.1:8000/todos/