Last active
October 22, 2016 16:23
-
-
Save buddylindsey/d4c6a3560606bf485b64943f56407a54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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