-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/search api #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
questions/views.py
Outdated
| overrides default queryset | ||
| """ | ||
| try: | ||
| keyword = self.request.GET['keyword'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use .get('keyword', ' ') this will return the second arg when keyword is empty.
questions/views.py
Outdated
| lists questions | ||
| """ | ||
|
|
||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. use .get('keyword', ' ')
| @@ -0,0 +1,5 @@ | |||
| <form action=""> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't leave action attr to empty, better to remove if empty
questions/views.py
Outdated
| Q(tags__name__icontains=keyword)).distinct() | ||
|
|
||
| queryset = questions | ||
| return queryset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not return questions right away? Instead of assigning to another variable.
| <div class="form-group col-sm-4 col-center-block"> | ||
| <form class="form-inline" (ngSubmit)="search(searchForm)" #searchForm="ngForm"> | ||
| <input class="form-control" type="text" name="keyword" ngModel> | ||
| <button style="border-radius: 0px 4px 4px 0px" class="btn" type="submit"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use inline css styling. move it to external css.
questions/views.py
Outdated
| serializer = self.serializer_class(data=self.request.data) | ||
| if serializer.is_valid(): | ||
| serializer.update(question.id) | ||
| return Response(status=201) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status 201 is for newly created object.
| question = Question.objects.get(code=code) | ||
| serializer = QuestionSerializer(question) | ||
| serializer = self.serializer_class(question) | ||
| return Response(serializer.data, status=200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use status 201 for created
No description provided.