I have the following:
from django.contrib.auth.models import User
class ClientDetails(models.Model):
created_by = models.ForeignKey(User)
...
How do I make created_by default to the currently logged in user?
(I want to do this so I can hide it in the admin view mainly but also because when I save an instance I don’t want to be filling it every time)
Since you need to get the currently logged in user from a
requestobject you cannot get it in the model’ssave-method,but you can eg override the model admin’ssave_model-method: