{ "info": { "author": "irakli khitarishvili", "author_email": "iraklikhitarishvili@yahoo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only" ], "description": "Installation\r\n============\r\n\r\n::\r\n\r\n run pip install django_phonenumbers\r\n\r\nConfigure settings.py\r\n======================\r\n\r\n::\r\n\r\n Add django_phonenumbers to INSTALLED_APPS\r\n\r\nmanage.py\r\n=========\r\n\r\n::\r\n\r\n run manage.py collectstatic\r\n\r\nsettings.py\r\n===========\r\n\r\n\r\n.. code:: python\r\n\r\n PHONE_NUMBER_REGION = 'GE' \r\n PHONE_NUMBERS_FORMATS_BY_REGION = {\r\n 'GE': {\r\n 'pattern': '(\\\\d{3})(\\\\d{2})(\\\\d{2})(\\\\d{2})', 'format': '\\\\1 \\\\2-\\\\3-\\\\4', 'prefix_format': '+%s (%s)'\r\n },\r\n 'US': {\r\n 'pattern': '(\\\\d{3})(\\\\d{3})(\\\\d{4})', 'format': '\\\\1 \\\\2-\\\\3', 'prefix_format': '+%s (%s)'\r\n },\r\n }\r\n\r\n- \"PHONE_NUMBER_REGION\" determines which country region will be selected in admin's corresponding phone number field\r\n- \"PHONE_NUMBERS_FORMATS_BY_REGION\" is used in \"phone_number_format\" filter\r\n\r\nModel\r\n=====\r\n\r\n.. code:: python\r\n\r\n #models.py\r\n class MyModel(models.Model):\r\n ...\r\n phone_number = PhoneNumberField()\r\n ...\r\n\r\n def __str__(self):\r\n return str(self.phone_number)\r\n\r\n**\"phone_number\"** field's type will be **\"PhoneNumber\"**\r\n\r\n.. code:: python\r\n\r\n class PhoneNumber:\r\n def __init__(self, country_code=None, region_code=None, phone_number=None):\r\n \"\"\"\r\n :type country_code: str\r\n :type region_code: str\r\n :type phone_number: str\r\n \"\"\"\r\n self.country_code = country_code\r\n self.google_phone_number = None\r\n self.region_code = region_code\r\n self.phone_number = phone_number\r\n\r\n\"__str__\" and \"__repr__\" functions are overridden to return \"country_code\"+\" \"+\"phone_number\"\r\n\r\n**model.fields.PhoneNumberField** is using **form.fields.PhoneNumberField** in admin by default\r\n\r\n**model.fields.PhoneNumberField** and **form.fields.PhoneNumberField** is validating and formatting(in national format) entered number\r\n\r\n\r\n\r\nTemplate example\r\n================\r\n\r\n.. code:: html\r\n\r\n