Reputation: 1127
My endpoints.py have:
from wagtail.api.v2.endpoints import BaseAPIEndpoint
from .models import Week, Ingredient, Menu
class WeekAPIEndpoint(BaseAPIEndpoint):
model = Week
def register_endpoints(api_router):
api_router.register_endpoint('week', WeekAPIEndpoint)
And if I follow the link 127.0.0.1:8000/api/v2/week i get this:
Is it possible to raise data by one step in DRF endpoints? from here 127.0.0.1:8000/api/v2/week/1:
I opened issue in my github. Didn't want to create too big a question here.
Upvotes: 0
Views: 235
Reputation: 1127
As suggested by @Oleg here, the problem is solved by adding 1 line of code in the endpoints like there:
class WeekAPIEndpoint(BaseAPIEndpoint):
model = Week
listing_default_fields = BaseAPIEndpoint.listing_default_fields + ['year', 'week']
so its takes my "year" and "week" fields and picks them up, so my api endpoint looks good Thanks @oleg.
Upvotes: 1