Pregunta

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
¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top