vin_paste

Untitled

Jan 17th, 2021
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. forms.py:
  2.  
  3. from django import forms
  4. from .models import Customers
  5.  
  6.  
  7. class CustomerEnrollment(forms.ModelForm):
  8.  
  9.     class Meta:
  10.         model = Customers
  11.         fields = ('name', 'address', 'contact_no', 'email', 'sport_name', 'applied_date')
  12.  
  13.         widgets = {
  14.             'name': forms.CharField(attrs={'class': 'form-control', 'placeholder':'Enter Your Name',
  15.                                                     'onfocus':'this.placeholder = " "',
  16.                                                     'onblur':'this.placeholder = "Enter Your Name"'}),
  17.             'address': forms.CharField(attrs={'class': 'form-control', 'placeholder': 'Enter your mail ID',
  18.                                                     'onfocus': 'this.placeholder = " "',
  19.                                                     'onblur': 'this.placeholder = "Enter your mail ID"'}),
  20.             'contact_no': forms.IntegerField(attrs={'class': 'form-control', 'placeholder': 'Enter your Contact No',
  21.                                                     'onfocus': 'this.placeholder = " "',
  22.                                                     'onblur': 'this.placeholder = "Enter your Contact No"', 'required':'True'}),
  23.         }
  24.  
  25.  
  26. models:
  27. class Customers(models.Model):
  28.     name = models.CharField(default="-", max_length=50)
  29.     email = models.EmailField()
  30.     address = models.CharField(max_length=200, null=True)
  31.     contact_no = models.PositiveIntegerField(validators=[MaxValueValidator(999999999999)], null=True)
  32.     sport_name = models.CharField(max_length=100, null=True)
  33.     applied_date = models.DateField()
  34.     confirmation_status = models.BooleanField(default=False)
  35.  
  36.     def __str__(self):
  37.         return self.name
  38.  
  39.     class Meta:
  40.         verbose_name_plural = "Customers"
Advertisement
Add Comment
Please, Sign In to add comment