There's no automatic owner
property in a Django model. That's just an example of a field you might set in that method.
Django REST framework: does a Django model object have an owner attribute?
-
02-06-2022 - |
Frage
I went digging through the documentation and used pycharm to look at the documentation, but I do not understand what the line 'obj.owner' means. I believe that obj is a Django model that's being passed in. Is there a built-in attribute named 'owner' on the model object that is passed into the pre_save() method? Could someone point me to documentation this 'owner' attribute?
Thanks!
http://django-rest-framework.org/api-guide/generic-views.html#genericapiview
def pre_save(self, obj):
"""
Set the object's owner, based on the incoming request.
"""
obj.owner = self.request.user
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow