[Answered ]-Update / Save model date value directly from template?

2👍

✅

There always has to be a view to linked to the template. You need to hook up a view to carry out a CRUD action like what you’re trying to do.

If you won’t like to reload the template, you can use an AJAX request to the view to perform the CRUD action.

In your shared snippet, you created a model property that updates last_visit.

Note that this model’s last_visit is updated when template interpolation is carried out and not when the link is clicked which I suppose isn’t the behavior you’re gunning for.

<a href="{{ contact.update_visit_date }}"> 

Leave a comment