Reputation: 44
I intalled Phonenumber package via pip and mentioned in my installed apps. As well as imported the same as mentioned in documentation to my models.py Even re-checked at the stack answers most of the people did the installation and imported file, but why mine is not working can anyone help
pip install django-phonenumber-field[phonenumbers]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'phonenumber_field',
'rk003.apps.Rk003Config',
]
models.py
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField
# Create your models here.
class Agent(models.Model):
agency_name = models.CharField(max_length=200)
prop_name = models.CharField(max_length=30)
agency_address = models.CharField(max_length=300)
agency_city = models.CharField(max_length=50)
agency_country = models.CharField(max_length=50)
email_address = models.EmailField(max_length=50)
contact_nu = models.PhoneNumberField()
Error is as follows
File "/Users/rishipalsingh/Projects/notes/mdndjango/rk002/rk003/models.py", line 13, in Agent
contact_nu = models.PhoneNumberField()
AttributeError: module 'django.db.models' has no attribute 'PhoneNumberField'
Upvotes: 0
Views: 1129
Reputation: 378
Its suppose to be contact_nu = PhoneNumberField(). You are not importing the PhoneNumberField() field from models. You have already imported it from phonenumber_field.modelfields
Upvotes: 3