Skip to content

Instantly share code, notes, and snippets.

@buddylindsey
Last active October 22, 2016 16:23
Show Gist options
  • Save buddylindsey/d4c6a3560606bf485b64943f56407a54 to your computer and use it in GitHub Desktop.
Save buddylindsey/d4c6a3560606bf485b64943f56407a54 to your computer and use it in GitHub Desktop.
from django.conf.urls import url
from django.shortcuts import render
from django.contrib.auth.models import User
from django.views.generic import ListView
urlpatterns = [
url(r'^$', index, name='index'),
url(r'^index2/$', IndexView.as_view, name='index2')
]
def index(request):
users = User.objects.all()
context = {'users': users, 'staff': User.objects.filter(is_staff=True)}
return render(request, 'home/index.html', context)
class IndexView(ListView):
model = User
context_object_name = 'users'
template_name = 'home/index.html'
def get_context_data(self, **kwargs):
context = super()
context['staff'] = User.objects.filter(is_staff=True)
return context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment