Reputation: 30101
I need to be able to insert numbers like 098532
into my table. This is the exact same question as this but I actually need to store it with the leading zeros as I will be using the data for 3rd party API calls.
The given answer was to format the output which doesn't really solve my problem.
Is the best solution to change the datatype of the column to a CHAR
field?
Upvotes: 3
Views: 2241
Reputation: 2747
I think your best bet is to store it as a string in a charfield and then cast it when you need something else. i.e.
num = "051"
int(num)
if you need it as an int. Could you give a little more information about what the api expects and why you need the leading zeroes?
Upvotes: 4