Ishwar Chincholkar
Ishwar Chincholkar

Reputation: 666

invalid literal for int() with base 10:

In the view, I get the error message: invalid literal for int() with base 10

views.py

author_id = request.POST.get('id_author')
input_author= Engineer.objects.get(id=author_id)

Upvotes: 0

Views: 877

Answers (1)

knbk
knbk

Reputation: 53649

The items in the POST dictionary are strings by default. You must convert them to integers using the int method:

author_id = int(request.POST.get('id_author'))
input_author = Engineer.objects.get(id=author_id)

Upvotes: 2

Related Questions