1
Pointer
7y

FUCKING SHIT, I HATE THIS

Does anyone have problems with axios?

I've been trying to make this work for at least 1 hour. If I use Postman, it works alright, but using axios messes it up.

Practically what happens it's that Django does not picks the foreign keys, it loads all the fields except those two.

I've been like fucking crazy trying to understand what's going on but to no avail... I want to die, it's friday and this stupid thing is delaying me more than it should

Comments
  • 0
    @AlexDeLarge I'm not sure right now.

    I have this setup:

    Django + REST Framework + JWT for backend

    NuxtJS + Axios for Frontend

    I have an endpoint '/buildings', If I POST, it succeeds, no probs.

    But, if I first make a GET /cities, then POST /buildings, Django stops recognizing the fields "state" and "city" of my request.

    In other words,

    First request, the data looks like this:

    { name, address, state, city, ...}

    Then, after doing the two steps I mentioned earlier, all that Django sees is:

    {name, address, ...} (yeah, no state nor city field, wtf)

    I've been debugging and all I can see is that whenever that happens, the _writable_fields of the serializer does not contain the entries for both the state and city objects. BUT, as soon as I do a GET to /buildings AND POST thereafter, it works, wtf.
  • 0
    Oh yeah, by now I've ruled out Axios as the issue, I just thought It'd be, but I tested again with both Postman and PyCharm's integrated REST tool and the issue remains (or fluctuates, it's driving me nuts)
  • 0
    Oh yeah, I forgot to mention, I've debugged and the request always contains the fields, it's just that django-rest serializator it's not loading them
Add Comment