Phone number field in form/ model

2,481 views
Skip to first unread message

Sithembewena Lloyd Dube

unread,
Dec 14, 2016, 7:37:02 PM12/14/16
to django...@googlegroups.com
Hi,

Has anyone captured phone number information using a Form/ModelForm instance? I have the field as an IntegerField in my model and (for obvious reasons) it truncates the leading '0'. How have you solved this problem, anyone?

--
Regards,
Sithembewena

Fabio C. Barrionuevo da Luz

unread,
Dec 14, 2016, 7:48:04 PM12/14/16
to django...@googlegroups.com
Use CharField and try to find on https://django-localflavor.readthedocs.io/en/latest/ a Phone form Field for valid to you country or create 

Or create your own PhoneFormField with the validation rules that you need 

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAH-SnCD_zD980PLhau2eoGrKYy22%2BCorCB%2Bu%2BR5MwFUoY0rDhg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul


Blog colaborativo sobre Python e tecnologias Relacionadas, mantido totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e mandar o pull-request. Leia mais sobre como publicar em README.md e contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python ou é útil para quem usa Python? Está esperando o que? Publica logo, que estou louco para ler...

Michal Petrucha

unread,
Dec 14, 2016, 7:48:24 PM12/14/16
to django...@googlegroups.com
Easy – don't use integer input fields for phone numbers, use input
fields for short text strings with appropriate validation.

For example, you might want to look at some of the phone number fields
implemented in https://django-localflavor.readthedocs.io/en/latest/,
and take some inspiration from them.

Cheers,

Michal
signature.asc

Sithembewena Lloyd Dube

unread,
Dec 14, 2016, 8:32:32 PM12/14/16
to django...@googlegroups.com
Thanks guys!

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Sithembewena

Deep Shah

unread,
Dec 15, 2016, 1:12:48 PM12/15/16
to Django users
I have not tried this out but you can check this- 

https://github.com/stefanfoulis/django-phonenumber-field/

John Fabiani

unread,
Dec 15, 2016, 1:42:39 PM12/15/16
to django...@googlegroups.com
django-phonenumber-field is expecting a charfield and not a int.
Johnf

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages