What’s the best way to store a phone number in Django models?

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 universal way to store phone numbers, in particular if you have international numbers work with. Phone by PhoneNumberField … Read more

How to limit the maximum value of a numeric field in a Django model?

You can use Django’s built-in validators— from django.db.models import IntegerField, Model from django.core.validators import MaxValueValidator, MinValueValidator class CoolModelBro(Model): limited_integer_field = IntegerField( default=1, validators=[ MaxValueValidator(100), MinValueValidator(1) ] ) Edit: When working directly with the model, make sure to call the model full_clean method before saving the model in order to trigger the validators. This is not … Read more