“This field is required” when sending a POST request in Django Rest API Fremework, and axios?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
70 views
Want to send a post request, but for some reason returns me 400 pages and comes in response This field is required

post.vue
methods: { sendMessage () { let options = { params: { title: this.title body: this.textField article: this.article.id }, headers: { 'Content-Type': 'application/json' }, } HTTP.post('/comments/', options) .then(response => { this.$message({ type: 'success', message: 'Your comment is waiting for claims' }) console.log(response) }) .catch(err => { console.log(err) }) },


views.py
class CommentsView(viewsets.ModelViewSet): queryset = Comments.objects.all() serializer_class = CommentSerializer
by | 70 views

3 Answers

0 like 0 dislike
by
0 like 0 dislike
How you made the model?
by
0 like 0 dislike
Solved the problem, it was necessary to put models.py, blank=true, null=true
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users