how do i get the firstname and lastname in api in wagtail??
there is one form in the page..when I add firstname and lastname in form then it should display in api in front end
firstname and lastname should display in api front end
how to do this??
form/models.py
from django.db import models
# Create your models here.
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
from wagtail.api import APIField
from django import forms
from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import models
from django.shortcuts import render
from modelcluster.fields import ParentalKey, ParentalManyToManyField
from modelcluster.contrib.taggit import ClusterTaggableManager
from rest_framework.fields import Field
from taggit.models import TaggedItemBase
from wagtail.api import APIField
class FormField(AbstractFormField):
page = ParentalKey('FormPage', on_delete=models.CASCADE, related_name='form_fields')
class FormPage(AbstractEmailForm):
def get_api_representation(self, value,context=None):
return "anything"
template = "form.html"
content_panels = AbstractEmailForm.content_panels + [
InlinePanel('form_fields', label="Form fields"),
]
@property
def form_fields(self):
return self.form.fields
api_fields = [
# This is using a custom django rest framework serializer
APIField("form_fields"),
]
api_fields
as per docs.wagtail.io/en/stable/advanced_topics/api/v2/… – LB Ben Johnston