def first_run_view(request):
    user_count = User.objects.all().exclude(username='worker_process').count()
    if (user_count > 0):
        return HttpResponseRedirect('/')
    if (request.method == 'POST'):
        form = FirstRunForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(form.cleaned_data['username'], password=form.cleaned_data['password1'])
            user.is_superuser = True
            user.is_staff = True
            user.save()
            login(request, user)
            return HttpResponseRedirect('/')
        else:
            template = loader.get_template('registration/first-run.html')
            return HttpResponse(template.render({}, request))
    else:
        template = loader.get_template('registration/first-run.html')
        return HttpResponse(template.render({}, request))
def first_run_view(request):
    user_count = User.objects.all().exclude(username='worker_process').count()
    if (user_count > 0):
        return HttpResponseRedirect('/')
    if (request.method == 'POST'):
        form = FirstRunForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(form.cleaned_data['username'], password=form.cleaned_data['password1'])
            user.is_superuser = True
            user.is_staff = True
            user.save()
            login(request, user)
            return HttpResponseRedirect('/')
        else:
            template = loader.get_template('registration/first-run.html')
            return HttpResponse(template.render({}, request))
    else:
        template = loader.get_template('registration/first-run.html')
        return HttpResponse(template.render({}, request))