I'm using django-phonenumber_field
in my model, but when added a PhoneNumberField
in my model, and add it to my forms.py
file it does not show a country flag with their country code like this in template, how can i solve this problem?
from phonenumber_field.modelfields import PhoneNumberField
from django.core.validators import RegexValidator
class Product(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=50)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
description = models.TextField(max_length=1000)
phone_number = PhoneNumberField(validators=[RegexValidator(r'^\d{3}-\d{3}-\d{4}$')])
from phonenumber_field.formfields import PhoneNumberField
class ProductForm(forms.ModelForm):
phone_number = PhoneNumberField()
class Meta:
model = Product
fields = ['name', 'category', 'description', 'phone_number']
settings.py:
PHONENUMBER_DB_FORMAT = 'INTERNATIONAL'
PHONENUMBER_DB_FORMAT="RFC3966"