django-validation

What's the best way to store Phone number in Django models

╄→尐↘猪︶ㄣ 提交于 2019-11-27 05:49:31
I am storing a phone number in model like this: phone_number = models.CharField(max_length=12) User would enter a phone number and I would use the phone number for SMS Authentication This application would be used globally. So I would also need country code. Is CharField a good way to store phone number? And, how do I validate the phone number? Thanks in advance. erewok You might actually look into the internationally standardized format E.164 , recommended by Twilio for example (who have a service and an API for sending SMS or phone-calls via REST requests). This is likely to be the most

Custom form validation

ぃ、小莉子 提交于 2019-11-27 04:11:30
问题 I have a pretty simple form: from django import forms class InitialSignupForm(forms.Form): email = forms.EmailField() password = forms.CharField(max_length=255, widget = forms.PasswordInput) password_repeat = forms.CharField(max_length=255, widget = forms.PasswordInput) def clean_message(self): email = self.clean_data.get('email', '') password = self.clean_data.get('password', '') password_repeat = self.clean_data.get('password_repeat', '') try: User.objects.get(email_address = email) raise

What's the best way to store Phone number in Django models

半城伤御伤魂 提交于 2019-11-26 10:06:04
问题 I am storing a phone number in model like this: phone_number = models.CharField(max_length=12) User would enter a phone number and I would use the phone number for SMS Authentication This application would be used globally. So I would also need country code. Is CharField a good way to store phone number? And, how do I validate the phone number? 回答1: You might actually look into the internationally standardized format E.164, recommended by Twilio for example (who have a service and an API for

Why doesn't django's model.save() call full_clean()?

冷暖自知 提交于 2019-11-26 05:14:56
问题 I\'m just curious if anyone knows if there\'s good reason why django\'s orm doesn\'t call \'full_clean\' on a model unless it is being saved as part of a model form. Note that full_clean() will not be called automatically when you call your model’s save() method. You’ll need to call it manually when you want to run one-step model validation for your own manually created models. django\'s full clean doc (NOTE: quote updated for Django 1.6... previous django docs had a caveat about ModelForms