Why do we write [0] after get_or_create in model_name.object.get_or_create() in django
The function you're calling returns a list or a tuple. In either case, the [0] simply extracts the first element from the result, and throws any remaining results away.
A function in Faker script to add data in my model Department.
    
department = ['I.T.','C.S.E','M.E.','E.C.']
def add_dept():
    d = Department.objects.get_or_create(dept_name=random.choice(depatment))[0]