문제

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
도움이 되었습니까?

해결책

There's no automatic owner property in a Django model. That's just an example of a field you might set in that method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top