python - create view similar to another one -
i have make changes in django project , though i'm familiar python, i'm not django.
this situation:
i have table field "active". need let users sort table based on value of field (yes/no).
i looked views.py , realized there view sorts table based on id:
users = user.objects.all().order_by('id')
my questions are:
- how can make view sort table based on url parameter?
- do have create view or can use same kind of modifications?
you can use same view.
def myview(request): get_param = request.get.get('my_param', 'id') #some more processing users = user.objects.order_by(get_param) #note - dont need `all()` #rest of code here.
Comments
Post a Comment