I have a model called 'Candidate', which has the fields Experience,New Experience,Date_posted.
I'm using CreateView form to store the values in the database. When I enter experience and date_posted(set to timezone.now) for the first time, the 'new experience' value should also be set to 'experience' value by default. Now this 'new experience' value should get incremented after every month.
For example, experience=2.4 ( 2 years 4 months ), new experience =2.4( set automatically )
So, If I open my template(website page) 1 month from now, the 'experience' and 'date_posted' values must be same, but 'new experience' = 2.5 ( 2 years, 5 months )
class CandidateCreateView(LoginRequiredMixin, CreateView):
model = Candidate
fields = ['candidate_name', 'experience', 'email', 'new_experience']
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
Also, I want to use the format, 2.12 ( for 2 years 12 months )and 3.1 ( for 2 years 13 months ). How do I achieve this?