3👍
views.py
from django.views.generic.edit import UpdateView
from myapp.models import Author
class AuthorUpdate(UpdateView):
model = Author
fields = ['name']
template_name_suffix = '_update_form'
app/author_update_form.html
{% if request.user.is_authenticated and request.user.is_admin %}
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update">
</form>
{% else %}
<p>Display data</p>
{% endif %}
Source:stackexchange.com