Added example of PhoneNumberTYpe
This commit is contained in:
		| @@ -56,6 +56,14 @@ SQLAlchemy-Utils provides various new data types for SQLAlchemy. | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types | ||||
|  | ||||
|  | ||||
| ArrowType | ||||
| ^^^^^^^^^ | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types.arrow | ||||
|  | ||||
| .. autoclass:: ArrowType | ||||
|  | ||||
| ChoiceType | ||||
| ^^^^^^^^^^ | ||||
|  | ||||
| @@ -97,6 +105,22 @@ NumberRangeType | ||||
| .. autoclass:: NumberRangeType | ||||
|  | ||||
|  | ||||
| PasswordType | ||||
| ^^^^^^^^^^^^ | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types.password | ||||
|  | ||||
| .. autoclass:: PasswordType | ||||
|  | ||||
|  | ||||
| PhoneNumberType | ||||
| ^^^^^^^^^^^^^^^ | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types.phone_number | ||||
|  | ||||
| .. autoclass:: PhoneNumberType | ||||
|  | ||||
|  | ||||
| ScalarListType | ||||
| ^^^^^^^^^^^^^^ | ||||
|  | ||||
| @@ -105,6 +129,15 @@ ScalarListType | ||||
| .. autoclass:: ScalarListType | ||||
|  | ||||
|  | ||||
| TimezoneType | ||||
| ^^^^^^^^^^^^ | ||||
|  | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types.timezone | ||||
|  | ||||
| .. autoclass:: TimezoneType | ||||
|  | ||||
|  | ||||
| URLType | ||||
| ^^^^^^^ | ||||
|  | ||||
| @@ -122,14 +155,8 @@ UUIDType | ||||
| .. autoclass:: UUIDType | ||||
|  | ||||
|  | ||||
| TimezoneType | ||||
| ^^^^^^^^^^^^ | ||||
|  | ||||
|  | ||||
| .. module:: sqlalchemy_utils.types.timezone | ||||
|  | ||||
| .. autoclass:: TimezoneType | ||||
|  | ||||
|  | ||||
| The generates decorator | ||||
| ----------------------- | ||||
|   | ||||
| @@ -76,6 +76,21 @@ class PhoneNumberType(types.TypeDecorator, ScalarCoercible): | ||||
|     changes them back to PhoneNumber objects on the way out. If E164 is used | ||||
|     as storing format, no country code is needed for parsing the database | ||||
|     value to PhoneNumber object. | ||||
|  | ||||
|     :: | ||||
|  | ||||
|         class User(self.Base): | ||||
|             __tablename__ = 'user' | ||||
|             id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) | ||||
|             name = sa.Column(sa.Unicode(255)) | ||||
|             phone_number = sa.Column(PhoneNumberType()) | ||||
|  | ||||
|  | ||||
|         user = User(phone_number='+358401234567') | ||||
|  | ||||
|         user.phone_number.e164  # u'+358401234567' | ||||
|         user.phone_number.international  # u'+358 40 1234567' | ||||
|         user.phone_number.national  # u'040 1234567' | ||||
|     """ | ||||
|     STORE_FORMAT = 'e164' | ||||
|     impl = types.Unicode(20) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Konsta Vesterinen
					Konsta Vesterinen