1👍
✅
You should cast the 0 to unicode or string before concatenating.
fab = "0" + fab
You can not concatenate a unicode variable with an integer, you can also not concatenate strings with integers or floats, so you need to convert one to the correct type.
1👍
It sounds like your logic is wrong somewhere,
You are either trying to force an integer into a CharField
or you are trying to force a string into an IntegerField
. If its the former you’re always going to struggle with having to cast values to get the correct results and if its the latter the leading 0 is pointless.
You should try to use the correct field type, it will even help with your model’s validation.
- [Answered ]-Is it possible to pause and resume an http file upload?
- [Answered ]-Website goes unresponsive after directing to https in nginx server
- [Answered ]-Using ManyToManyFields() with Django
- [Answered ]-Getting certain values to appear in django form
Source:stackexchange.com