Skip to content

Conversation

@Chibi-Shem
Copy link
Contributor

No description provided.

overrides default queryset
"""
try:
keyword = self.request.GET['keyword']

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.

lists questions
"""

try:

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="">
Copy link

@mcandidier mcandidier Jul 16, 2018

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

Q(tags__name__icontains=keyword)).distinct()

queryset = questions
return queryset

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">

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.

serializer = self.serializer_class(data=self.request.data)
if serializer.is_valid():
serializer.update(question.id)
return Response(status=201)

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)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants