django - “Incorrect type. Expected pk value, received str” error

前端 未结 2 886
青春惊慌失措
青春惊慌失措 2021-01-11 10:23

I my django-rest-framework I have the following models:

Basically every ride has one final destination and can have multiple middle destinations.

mod

2条回答
  •  青春惊慌失措
    2021-01-11 11:12

    Angular/Django Rest Framework

    I had similar problem when trying to post a formdata that has a field with some array values. It turned out that I was using a wrong content-type in the post headers of angular frontend. All I needed was comment out Content-Type.

      Post(endpoint, postData) {
        let auth = `Bearer ${this.token}`;
        let headers = new HttpHeaders({
          // "Content-Type": "application/x-www-form-urlencoded",
          Authorization: auth
        });
        let fullurl = `${this.baseUrl}${endpoint}`;
       .....
      ....
    }
    

提交回复
热议问题