localwiki / localwiki-backend-server

Primary LocalWiki backend server environment
GNU General Public License v2.0
48 stars 16 forks source link

Paging through some api endpoints not working #74

Closed sethvincent closed 9 years ago

sethvincent commented 9 years ago

Stumbled on an issue with the maps endpoint, and found that I had the same issue with the tags_history & maps_history endpoints.

Examples:

GET https://localwiki.org/api/v4/maps/?page=1&format=json

returns

{
  count: 0,
  next: null,
  previous: null,
  results: [ ]
}

GET https://localwiki.org/api/v4/maps/?page=2&format=json

returns

{
  detail: "Not found"
}

Leaving off the page param works as expected: https://localwiki.org/api/v4/maps/?format=json

But as soon as I go to the next url it returns not found.

philipn commented 9 years ago

Looks like this doesn't happen on resources without a 'page' attribute, so I guess that's the problem here.

@sethvincent, if you have the dev server running locally you may want to look up Django Rest Framework's pagination parameter name and try an alternative and see if it works.

Not sure what we should rename the parameter to, maybe '_page' or 'p'?

On Feb 4, 2015, at 4:48 PM, Seth Vincent notifications@github.com wrote:

Stumbled on an issue with the maps endpoint, and found that I had the same issue with the tags_history & maps_history endpoints.

Examples:

GET https://localwiki.org/api/v4/maps/?page=1&format=json

returns

{ count: 0, next: null, previous: null, results: [ ] } GET https://localwiki.org/api/v4/maps/?page=2&format=json

returns

{ detail: "Not found" } Leaving off the page param works as expected: https://localwiki.org/api/v4/maps/?format=json

But as soon as I go to the next url it returns not found.

— Reply to this email directly or view it on GitHub.

philipn commented 9 years ago

@sethvincent Unfortunately looks more complicated than a simple setting. I'm working on fixing Django Rest Framework to allow for pagination parameters that aren't named page.

philipn commented 9 years ago

@sethvincent Pretty involved fix, unfortunately. But should now be working. New next links use p rather than page, e.g.:

GET https://localwiki.org/api/v4/maps/?p=1&format=json
sethvincent commented 9 years ago

Cooool. Thanks! Single p makes sense. I'll continue on the map-related api stuff I was working on.