Skip to content Skip to sidebar Skip to footer

Pass Value From View To Controller And Display In Template

I need to pass the latest value from a database field to the controller. I'm also in due to perform certain calculations with respect to the value I get from the view in the contro

Solution 1:

Do you need just the latest by date or latest by insert into DB? That's kinda different.

def get_context_data(self, **kwargs):

   latest_id = SiverifyVerificationSiteRevision.objects.latest('date').id  # `latest` method works on date fields.

   # This one gives you latest ID by insert.
   # latest_id = SiverifyVerificationSiteRevision.objects.order_by('-id').first().id

   kwargs['latest_id'] = latest_id
   kwargs['ngapp'] = 'ReviewMod'

   return kwargs

Post a Comment for "Pass Value From View To Controller And Display In Template"