From 5335a18cc2ab480739e5fda6865114abbaa445a0 Mon Sep 17 00:00:00 2001 From: davy39 Date: Sun, 23 Jan 2022 15:10:22 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20format=20num=C3=A9ro=20de=20t?= =?UTF-8?q?=C3=A9l=C3=A9phone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- djangoLxp/settings.py | 9 ++++++++- inscription/models.py | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/djangoLxp/settings.py b/djangoLxp/settings.py index 6793b0f..75f21fd 100644 --- a/djangoLxp/settings.py +++ b/djangoLxp/settings.py @@ -10,7 +10,6 @@ import os from dotenv import load_dotenv -CRISPY_TEMPLATE_PACK = 'bootstrap4' LOGIN_URL='/admin/login/' ALLOWED_HOSTS = ['davy39.pythonanywhere.com', '127.0.0.1', 'https://lxp-app.herokuapp.com', 'inscription.cf'] @@ -18,6 +17,10 @@ MIGRATION_MODULES = {'captcha': 'migrations.captcha', 'address': 'migrations.address', 'inscription': 'migrations.inscription'} +# Format des numeros de téléphone avec django-phonenumber-field +PHONENUMBER_DB_FORMAT = 'NATIONAL' +PHONENUMBER_DEFAULT_REGION = 'FR' + # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ USE_I18N = True @@ -174,6 +177,10 @@ STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) + + +CRISPY_TEMPLATE_PACK = 'bootstrap4' + import django_heroku # Attention : s'il n'y a pas staticfiles=False le dossier par défaut static_root ou AWS n'est pas utilisé diff --git a/inscription/models.py b/inscription/models.py index 5fb4fb5..7b8b9e0 100644 --- a/inscription/models.py +++ b/inscription/models.py @@ -83,8 +83,7 @@ def __iter__(self): nom_usage = models.CharField(max_length=255, verbose_name="Nom d'usage", help_text="Comment souhaites-tu qu'on t'appelle au lycée ?") email = models.EmailField(max_length=255, verbose_name="Email") - telephone = models.CharField(max_length=255, blank=True, null=True, - verbose_name="Téléphone") + telephone = PhoneNumberField(verbose_name="Téléphone") comments = models.TextField(blank=True, null=True, verbose_name="Commentaires") hash = models.CharField(max_length=30, default=create_hash, unique=True) photo = models.ImageField(upload_to=nom_photo, null=True)