Answer the question
In order to leave comments, you need to log in
How to hide or make it impossible to edit input in the admin?
Made model with user = models.ForeignKey(). It is used by all users/groups who have rights to create a post, but it needs to be editable only by superusers (only 1 input from the entire form). Where should I write the check? As far as I understand, then models is work with the database, it turns out that you need to write in admin.py?
class Post(models.Model):
user = models.ForeignKey(
User,
verbose_name="Пользователь",
on_delete=models.CASCADE,
default = User.id)
Answer the question
In order to leave comments, you need to log in
Django documentation / The Django admin site / ModelAdmin options / ModelAdmin.readonly_fields
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question