Skip to content

Instantly share code, notes, and snippets.

@pirate
Last active June 10, 2020 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirate/afd404a1cb1c790f0c24f646c9da6b19 to your computer and use it in GitHub Desktop.
Save pirate/afd404a1cb1c790f0c24f646c9da6b19 to your computer and use it in GitHub Desktop.
from django.views import View
from django.shortcuts import render
class Leaderboard(View):
title = 'Leaderboard'
template = 'ui/react_base.html'
component = 'pages/leaderboard.js'
def get(self, request):
# gets passed to react via window.props
props = {
'users': [
{'username': 'alice'},
{'username': 'bob'},
]
}
context = {
'title': self.title,
'component': self.component,
'props': props,
}
return render(request, self.template, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment