Generating a Random Hex Color in Python

For a Django App, each “member” is assigned a color to help identify them. Their color is stored in the database and then printed/copied into the HTML when it is needed. The only issue is that I am unsure how to generate random Hex colors in python/django. It’s easy enough to generate RGB colors, but to store them I would either need to a) make three extra columns in my “Member” model or b) store them all in the same column and use commas to separate them, then, later, parse the colors for the HTML. Neither of these are very appealing, so, again, I’m wondering how to generate random Hex colors in python/django.

@csrf_exempt does not work on generic view based class

class ChromeLoginView(View): def get(self, request): return JsonResponse({'status': request.user.is_authenticated()}) @method_decorator(csrf_exempt) def post(self, request): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return JsonResponse({'status': True}) return JsonResponse({'status': False}) I am expecting that the post does stopped by csrf, but it return 403 error. But if remove … Read more