Open yeppin opened 3 years ago
Yes, please follow the given example at hw4 specification and change 'author_id' key into 'author'.
from .models import Article, Comment
new_user = User.objects.create_user(username='swpp', password='iluvswpp') # Django default user model
new_article = Article(title='I Love SWPP!', content='Believe it or not', author=new_user)
new_article.save()
new_comment = Comment(article=new_article, content='Comment!', author=new_user)
new_comment.save()
I have a question regarding the format of jsonResponse as the result of http GET request. Is it okay if I got a jsonResponse like below for the GET
/api/article/
, when I only had this one object? [{'id': 1, 'title': 'I Love SWPP!', 'content': 'Believe it or not', 'author_id': 1}]I wondered if I should change 'author_id' key into 'author'.