pipenv shell
wagtail start backend
cd backend
pip install -r requirements.txt
python manage.py migrate
set up databasepython manage.py runserver
localhost8000python manage.py createsuperuser
python manage.py startapp news
- in
backend > settings > base.py
add news to INSTALLED_APPS list - in
news > models.py
:- Create a new wagtail page
python manage.py makemigrations
python.manage.py migrate
- in /admin create a new child page.
news page
should be listed, with a title, intro, and body!
- add
wagtail.api.v2
to INSTALLED_APPS insettings > base.py
- configure endpoints/views
- in the same folder as
urls.py
(backend folder) create a new file calledapi.py
- copy and paste setup from doc
- in the same folder as
- Regiseter the URLS so Django can route requests into the API:
- in
urls.py
addpath('api/v2/', api_router.urls),
to URL_PATTERNS
- in
- add an api_fields list to
news > models.py
http://localhost:8000/api/v2/pages/
shows pages API
- axios.get('/api-of-backend') in frontend
- for every article in articles {}
news.NewsPage&fields=intro,body
specifies fields in api- to avoid CORS error in developement:
pip install django-cors-headers
corsheaders
in base.py INSTALLED_APPS- add middleware
CORS_ORIGIN_ALLOW_ALL = True
in base.py