On 20/04/2022 11.33, Ankit Chaurasia wrote:
> from django.db import models
> class Customer(models.Model):
> name = models.CharField(max_length=20)
> phone = models.IntegerField()
> I want to concatenate name + last digit of phone number.
>
It makes no sense to store a phone number as an integer. A phone number
is not something you can increment, decrement or do similar arithmetic
operations with.
Just use a CharField or probably even better, a field dedicated to phone
numbers:
https://pypi.org/project/django-phonenumber-field/
Using a more proper field type will make it simple to do the
concatenation using standard Python.
Kind regards,
Kasper Laudrup