text: from django import forms
  from django.contrib.auth import authenticate
  from django.contrib.auth import get_user_model
  from django.contrib import auth
  
  from jobapp.models import *
  from ckeditor.widgets import CKEditorWidget
  
  
      
  
  class JobForm(forms.ModelForm):
      
      def __init__(self, *args, **kwargs):
          forms.ModelForm.__init__(self, *args, **kwargs)
          self.fields['title'].label = "Job Title :"
          self.fields['location'].label = "Job Location :"
          self.fields['salary'].label = "Salary :"
          self.fields['description'].label = "Job Description :"
          self.fields['tags'].label = "Tags :"
          self.fields['last_date'].label = "Submission Deadline :"
          self.fields['company_name'].label = "Company Name :"
          self.fields['url'].label = "Website :"
  
  
          self.fields['title'].widget.attrs.update(
              {
                  'placeholder': 'eg : Electritcian Carpenter Plumber Cook',
              }
          )        
          self.fields['location'].widget.attrs.update(
              {
                  'placeholder': 'eg : Athwa Surat Vesu',
              }
          )
          self.fields['salary'].widget.attrs.update(
              {
                  'placeholder': 'Rs.2000-5000 Per month',
              }
          )
          self.fields['tags'].widget.attrs.update(
              {
                  'placeholder': 'Use comma separated. eg: Electrical, Repair, Cook, Food, Carpentry',
              }
          )                        
          self.fields['last_date'].widget.attrs.update(
              {
                  'placeholder': 'YYYY-MM-DD ',
                  
              }
          )        
          self.fields['company_name'].widget.attrs.update(
              {
                  'placeholder': 'Company Name Or Orginization Name',
              }
          )           
          self.fields['url'].widget.attrs.update(
              {
                  'placeholder': 'https://xyz.com',
              }
          )    
  
  
      class Meta:
          model = Job
  
          fields = [
              "title",
              "location",
              "job_type",
              "category",
              "salary",
              "description",
              "tags",
              "last_date",
              "company_name",
              "company_description",
              "url"
              ]
  
      def clean_job_type(self):
          job_type = self.cleaned_data.get('job_type')
  
          if not job_type:
              raise forms.ValidationError("Service is required")
          return job_type
  
      def clean_category(self):
          category = self.cleaned_data.get('category')
  
          if not category:
              raise forms.ValidationError("category is required")
          return category
  
  
      def save(self, commit=True):
          job = super(JobForm, self).save(commit=False)
          if commit:
              user.save()
          return job
  
  
  
  
  class JobApplyForm(forms.ModelForm):
      class Meta:
          model = Applicant
          fields = ['job']
  
  class JobBookmarkForm(forms.ModelForm):
      class Meta:
          model = BookmarkJob
          fields = ['job']
  
  
  
  
  class JobEditForm(forms.ModelForm):
      
      def __init__(self, *args, **kwargs):
          forms.ModelForm.__init__(self, *args, **kwargs)
          self.fields['title'].label = "Job Title :"
          self.fields['location'].label = "Job Location :"
          self.fields['salary'].label = "Salary :"
          self.fields['description'].label = "Job Description :"
          # self.fields['tags'].label = "Tags :"
          self.fields['last_date'].label = "Dead Line :"
          self.fields['company_name'].label = "Company Name :"
          self.fields['url'].label = "Website :"
   
  
          self.fields['title'].widget.attrs.update(
              {
                  'placeholder': 'eg : Electritcian Carpenter Plumber Cook',
              }
          )        
          self.fields['location'].widget.attrs.update(
              {
                  'placeholder': 'eg : Athwa Surat Vesu',
              }
          )
          self.fields['salary'].widget.attrs.update(
              {
                  'placeholder': 'Rs.2000-5000 Per month',
              }
          )
          # self.fields['tags'].widget.attrs.update(
          #     {
          #         'placeholder': 'Use comma separated. eg: Electrical, Repair, Cook, Food, Carpentry',
          #     }
          # )                        
          self.fields['last_date'].widget.attrs.update(
              {
                  'placeholder': 'YYYY-MM-DD ',
                  
              }
          )        
          self.fields['company_name'].widget.attrs.update(
              {
                  'placeholder': 'Company Name Or Orginization Name',
              }
          )           
          self.fields['url'].widget.attrs.update(
              {
                  'placeholder': 'https://xyz.com',
              }
          )    
  
      class Meta:
          model = Job
  
          fields = [
              "title",
              "location",
              "job_type",
              "category",
              "salary",
              "description",
              "last_date",
              "company_name",
              "company_description",
              "url"
              ]
  
      def clean_job_type(self):
          job_type = self.cleaned_data.get('job_type')
  
          if not job_type:
              raise forms.ValidationError("Service is required")
          return job_type
  
      def clean_category(self):
          category = self.cleaned_data.get('category')
  
          if not category:
              raise forms.ValidationError("category is required")
          return category
  
  
      def save(self, commit=True):
          job = super(JobEditForm, self).save(commit=False)
          if commit:
              user.save()
          return job
  
  