[Answer]-Failed to to turn django staff flag on programatically

1👍

Not that it will necessarily solve your problem, but the Django way to get a single record is Queryset.get

    try:
        u=User.objects.get(username=username)
    except User.DoesNotExist:
        raise Http404() 
    u.is_staff=True;
    u.save() #
    print u, u.is_staff

Also your view should only accept POST requests.

0👍

Can’t you just do a

User.objects.filter(username=username).update(is_staff=True)

It will update the data (without having to call save()) for every object the filter finds.

👤BriceP

Leave a comment