Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- forms.py:
- from django import forms
- from .models import Customers
- class CustomerEnrollment(forms.ModelForm):
- class Meta:
- model = Customers
- fields = ('name', 'address', 'contact_no', 'email', 'sport_name', 'applied_date')
- widgets = {
- 'name': forms.CharField(attrs={'class': 'form-control', 'placeholder':'Enter Your Name',
- 'onfocus':'this.placeholder = " "',
- 'onblur':'this.placeholder = "Enter Your Name"'}),
- 'address': forms.CharField(attrs={'class': 'form-control', 'placeholder': 'Enter your mail ID',
- 'onfocus': 'this.placeholder = " "',
- 'onblur': 'this.placeholder = "Enter your mail ID"'}),
- 'contact_no': forms.IntegerField(attrs={'class': 'form-control', 'placeholder': 'Enter your Contact No',
- 'onfocus': 'this.placeholder = " "',
- 'onblur': 'this.placeholder = "Enter your Contact No"', 'required':'True'}),
- }
- models:
- class Customers(models.Model):
- name = models.CharField(default="-", max_length=50)
- email = models.EmailField()
- address = models.CharField(max_length=200, null=True)
- contact_no = models.PositiveIntegerField(validators=[MaxValueValidator(999999999999)], null=True)
- sport_name = models.CharField(max_length=100, null=True)
- applied_date = models.DateField()
- confirmation_status = models.BooleanField(default=False)
- def __str__(self):
- return self.name
- class Meta:
- verbose_name_plural = "Customers"
Advertisement
Add Comment
Please, Sign In to add comment