1👍
You can add values in models:
class Book(models.Model):
title = models.TextField()
description = models.TextField()
lock = models.BooleanField()
last_change = models.DateTimeField()
last_user_change = models.ForeignKey(User)
and in view
def edit_book(request, pk):
book = get_object_or_404(Book, pk=pk)
user = request.user.id
if book.lock == 0:
book.lock = 1
book.save()
if request.method == "POST":
form = edit_bookForm(request.POST or None)
if form.is_valid():
f=form(commit=False)
f.last_change = datetime.now()
f.last_user_change = user
f.save()
book.lock = 0
book.save()
return redirect('ok')
return render(request, 'urformhtml.html', {})
else:
return render(request, 'byebye.html', {})
Or you can add last_change_title and last_change_description to split update….
Is only an idea
Source:stackexchange.com