1. You can override `.save` method of a model and detect that it is an update operation like this ``` def save(self, *args, **kwargs): if not self._state.adding: … ``` According to https://docs.djangoproject.com/en/3.0/ref/models/instances/ one can supply `update_fields` to the save method and then you can raise exception when that parameter is not to your liking during the update.
2. If you rely on DRF serializer, you can create a different serializer for updating 3. Since this is a forum on DRF, to prevent update via http, you write different views for PUT vs POST ie you allow insert into all fields in your POST view but updates on your whitelisted fields in PUT view. > On May 5, 2020, at 05:49, Андрей Казанцев <hec...@yandex.ru> wrote: > > I have a model with fields: A, B, C. I want all fields on create be > available, but on update only A filed to be avaliable. How to do this? > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-rest-framework+unsubscr...@googlegroups.com > <mailto:django-rest-framework+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/d3a6b838-ae44-4be1-8fcc-dfefb1a1506e%40googlegroups.com > > <https://groups.google.com/d/msgid/django-rest-framework/d3a6b838-ae44-4be1-8fcc-dfefb1a1506e%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/7F020274-AE5C-4C70-AA05-1DF32F2A310D%40gmail.com.