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

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/789404f7-e665-d102-1dee-406cbfcfe4cd%40stacktrace.dk.

Attachment: OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to