Commit 6c98c67e authored by Alice's avatar Alice

Add baseUrl on Readme.

parent 3f5a2e14
Pipeline #6512 passed with stage
in 1 minute and 30 seconds
...@@ -32,6 +32,7 @@ In the future it could also be used to auto configure django router (e.g. urls.p ...@@ -32,6 +32,7 @@ In the future it could also be used to auto configure django router (e.g. urls.p
```python ```python
from djangoldp.models import Model from djangoldp.models import Model
from django.db import models
class Todo(Model): class Todo(Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
...@@ -67,7 +68,7 @@ Note that this will be overridden if you explicitly set the fields= parameter as ...@@ -67,7 +68,7 @@ Note that this will be overridden if you explicitly set the fields= parameter as
4. Add a url in your urls.py: 4. Add a url in your urls.py:
```python ```python
from django.conf.urls import url from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
from djangoldp.views import LDPViewSet from djangoldp.views import LDPViewSet
from .models import Todo from .models import Todo
...@@ -80,20 +81,19 @@ urlpatterns = [ ...@@ -80,20 +81,19 @@ urlpatterns = [
This creates 2 routes for each Model, one for the list, and one with an ID listing the detail of an object. This creates 2 routes for each Model, one for the list, and one with an ID listing the detail of an object.
You could also only use this line in settings.py instead:
```python
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 5. In the settings.py file, add your application name at the beginning of the application list, and add the following lines
```python ```python
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')
LDP_RDF_CONTEXT = 'https://cdn.happy-dev.fr/owl/hdcontext.jsonld' LDP_RDF_CONTEXT = 'https://cdn.happy-dev.fr/owl/hdcontext.jsonld'
DJANGOLDP_PACKAGES=[]
SITE_URL = 'http://localhost:8000'
BASE_URL = SITE_URL
``` ```
6. You can also register your model for the django administration site 6. You can also register your model for the django administration site.
Create a admin.py file at the same level of your models.py file and fill it with the following code :
```python ```python
from django.contrib import admin from django.contrib import admin
...@@ -102,15 +102,46 @@ from .models import Todo ...@@ -102,15 +102,46 @@ from .models import Todo
admin.site.register(Todo) admin.site.register(Todo)
``` ```
7. You then need to have your WSGI server pointing on myldpserver/myldpserver/wsgi.py 7. Create a apps.py file at the same level of your model and fill it with the following code :
```python
from django.apps import AppConfig
class MyldpserverConfig(AppConfig):
name = 'myldpserver'
```
'
8. In your settings complete the INSTALLED_APPS, with `myldpserver` and `djangoldp` as show below.
```python
# Application definition
INSTALLED_APPS = [
'myldpserver',
'djangoldp',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
]
```
9. Make your migrations
8. You will probably need to create a super user ```bash
$ ./manage.py migrate
```
10. You will probably need to create a super user
```bash ```bash
$ ./manage.py createsuperuser $ ./manage.py createsuperuser
$ ./manage.py migrate --run-syncdb
``` ```
9. If you have no CSS on the admin screens : 11. If you have no CSS on the admin screens :
```bash ```bash
$ ./manage.py collectstatic $ ./manage.py collectstatic
...@@ -121,9 +152,11 @@ $ ./manage.py collectstatic ...@@ -121,9 +152,11 @@ $ ./manage.py collectstatic
To start the server, `cd` to the root of your Django project and run : To start the server, `cd` to the root of your Django project and run :
```bash ```bash
$ python3 manage.py runserver $ ./manage.py runserver
``` ```
Go to `127.0.0.1:8000/admin/` to access to your Django admin.
## Custom Parameters to LDPViewSet ## Custom Parameters to LDPViewSet
### lookup_field ### lookup_field
......
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