Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

custom validation in django models

from django.db import models
# importing validationerror
from django.core.exceptions import ValidationError
 
# creating a validator function
def validate_geeks_mail(value):
    if "@gmail.com" in value:
        return value
    else:
        raise ValidationError("This field accepts mail id of google only")
 
 
# Create your models here.
class GeeksModel(models.Model):
    geeks_mail = models.CharField(
                         max_length = 200,
                         validators =[validate_geeks_mail]
                         )
Comment

PREVIOUS NEXT
Code Example
Python :: python hash 
Python :: dictionary from two list 
Python :: how to unimport a file python 
Python :: python search a string in another string get last result 
Python :: python initialize multidimensional array 
Python :: python gui framework 
Python :: list remove method in python 
Python :: python codes for counting the occurrence of a letters in dictionary excluding digits 
Python :: find an item in a list python 
Python :: python herencia 
Python :: django-oauth 
Python :: implement stack using list in python 
Python :: what is the size of cover in facebook 
Python :: find index of value in list python 
Python :: set remove in python 
Python :: panda lambda function returns dataframe 
Python :: select each two elements on a list python 
Python :: insert blank row in data frame 
Python :: tensorflow Dense layer activatity leaklyrelu 
Python :: How to Remove Items in a Set in Python Using the discard() Method 
Python :: python call function that need args with decorator 
Python :: sample hyperparameter tuning with grid search cv 
Python :: delete file in django terminal 
Python :: field in django 
Python :: python add list 
Python :: add header info in django response 
Python :: longest palindromic substring using dp 
Python :: Dynamic Form Fields Django 
Python :: python how to vectorize a function 
Python :: python repr() 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =