Skip to content

Instantly share code, notes, and snippets.

@ihfazhillah
Created July 11, 2019 04:46
Show Gist options
  • Save ihfazhillah/f07d9ef8a4cfb7e0c07e32cffc936684 to your computer and use it in GitHub Desktop.
Save ihfazhillah/f07d9ef8a4cfb7e0c07e32cffc936684 to your computer and use it in GitHub Desktop.
# views.py
def detail_quiz(request, pk):
quiz = get_object_or_404(Quiz, pk=pk)
return render_template(request, templatename, {'quiz': quix})
# in template
{# to show questions #}
{% if request.user == quiz.created_by or request.user in quiz.students.all() %}
{% for question in quiz.questions.all() %}
{# show the questions %}
{% endfor %}
{% else %}
Only Registered user can see the questions
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment