TypeError: create() missing 1 required positional argument: 'vals' code example

Example 1: create_user() missing 1 required positional argument: 'username'

from django.shortcuts import render, redirect
from django.contrib.auth.models import User
# Create your views here.

def index(request):
    return render(request, 'index.html')

def register(request):
    if request.method == 'POST':
        print('hi hello')
        first_name = request.POST['first_name']
        email = request.POST['email']
        password = request.POST['password']
        user = User.objects.create_user(first_name=first_name, email=email, password=password)
        user.save()
        print('user Created')
        user.redirect('/')
    else:
        print('user not created')
        return render(request, 'register.html')

Example 2: TypeError: index() missing 1 required positional argument: 'doc_type'

res = es.search(index="people", doc_type="test", body={"query":{"match":{"name": "john"}}})

Tags:

Misc Example