python - app.models.MultipleObjectsReturned: get() returned more than one User -- it returned 17 -


i got error,app.models.multipleobjectsreturned: get() returned more 1 user -- returned 17! . wanna parse excel , put model(city&prefecture&area&user) . wrote

  fourrows_transpose = list(map(list, zip(*fourrows)))   val3 = sheet3.cell_value(rowx=0, colx=9)   user3 = user.objects.get(corporation_id=val3)   print(user3)   if user3:    area = area.objects.filter(name="america")    pref = prefecture.objects.create(name="prefecture", area=user3.area)    city = city.objects.create(name="city", prefecture=pref)    price_u1000 = price.upper1000.objects.get(city=city)    price_500_1000 = price.from500to1000.objects.get(city=city)    price_u500 = price.under500.objects.get(city=city)     pref.name = "ny"    pref.save()     in range(len(fourrows_transpose)):        city.name = fourrows_transpose[i][1]        city.save()        print(fourrows_transpose[i][1])         price_u1000.name = fourrows_transpose[i][2]        price_u1000.save()        print(fourrows_transpose[i][2])         price_500_1000.name = fourrows_transpose[i][3]        price_500_1000.save()        print(fourrows_transpose[i][3])         price_u500.name = fourrows_transpose[i][4]        price_u500.save()        print(fourrows_transpose[i][4]) 

i wanna put these data [['america', '', '', '', ''], ['', '', 'u1000', '500~1000', 'd500'], ['ny', 'city a', '×', '×', '×'], ['', 'city b', '×', '×', '×'], ['', 'city c', '×', '×', '×'], ['', 'city d', '×', '×', '×'], ['', 'city e', '×', '×', '×']] models 'america' prefecture's area , city city's name , × to price's name . how can fix this?what should write it?

try capture first record of instance using method first()

user3 = user.objects.filter(corporation_id=val3).first() 

it helps first record of particular object instance, these can you


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -